Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinhnx/dictionarynestedsubscript
Nested subscript for Dictionary.
https://github.com/vinhnx/dictionarynestedsubscript
demo github-package-registry smile swift swift-package-manager swiftpm xcode
Last synced: 4 months ago
JSON representation
Nested subscript for Dictionary.
- Host: GitHub
- URL: https://github.com/vinhnx/dictionarynestedsubscript
- Owner: vinhnx
- License: mit
- Created: 2019-06-11T05:43:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-17T13:45:49.000Z (almost 5 years ago)
- Last Synced: 2024-09-16T03:48:02.807Z (5 months ago)
- Topics: demo, github-package-registry, smile, swift, swift-package-manager, swiftpm, xcode
- Language: Swift
- Homepage:
- Size: 110 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DictionaryNestedSubscript
A Swift Package that enable nested `subscript` on `Dictionary`.
### Usage
```swift
import DictionaryNestedSubscriptlet 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...`

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

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

4. then click `Next` for Xcode to resolve the package.

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

6. Profit :smile:

### References
Guide
+ https://developer.apple.com/documentation/swift_packages/creating_a_swift_package_with_xcode
+ https://developer.apple.com/documentation/swift_packages/publishing_a_swift_package_with_xcodeInspiration
+ https://github.com/krzyzanowskim/CollectionSafeIndex (for the idea :smile:)
+ https://stackoverflow.com/a/41543070/1477298 (for the logic :rocket:)