DictionaryNestedSubscript

master

Nested subscript for Dictionary.
vinhnx/DictionaryNestedSubscript

DictionaryNestedSubscript

A Swift Package that enable nested subscript on Dictionary.

Usage

import DictionaryNestedSubscript

let dictionary: [String: Any] = [
    "countries": [
        "japan": [
            "capital": [
                "name": "tokyo",
                "lat": "35.6895",
                "lon": "139.6917"
            ],
            "language": "japanese"
        ]
    ]
]

dictionary[jsonDict: "countries"]?[jsonDict: "japan"]?[jsonDict: "capital"]?["name"] // "tokyo"

Integration (requires Xcode 11+)

  1. from your project, Choose Xcode > File > Swift Packages > Add Package Dependency...

demo

  1. put https://github.com/vinhnx/DictionaryNestedSubscript under Choose Package Repository field

demo

  1. (optional) specify the version or branch or specific commit you want to use from the package

demo

  1. then click Next for Xcode to resolve the package.

demo

  1. Choose where to add Package framework to your app's target

demo

  1. Profit 😄

demo

References

Guide

Inspiration

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Oct 20 2024 03:33:21 GMT-0900 (Hawaii-Aleutian Daylight Time)