https://github.com/willpowell8/dictionaryutils
iOS Dictionary Utilities for Swift - allowing you to pull properties from a dictionary using a string eg. data.readString("field[0].name")
https://github.com/willpowell8/dictionaryutils
cocoapods dictionary ios json objectmapper swift swift-library swift4 swiftyjson willpowell
Last synced: 6 months ago
JSON representation
iOS Dictionary Utilities for Swift - allowing you to pull properties from a dictionary using a string eg. data.readString("field[0].name")
- Host: GitHub
- URL: https://github.com/willpowell8/dictionaryutils
- Owner: willpowell8
- License: mit
- Created: 2017-04-01T17:42:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T15:17:50.000Z (over 6 years ago)
- Last Synced: 2025-04-09T23:53:43.845Z (6 months ago)
- Topics: cocoapods, dictionary, ios, json, objectmapper, swift, swift-library, swift4, swiftyjson, willpowell
- Language: Swift
- Homepage: http://www.willpowell.co.uk
- Size: 32.2 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# DictionaryUtilsDictionary utils allows you to use JSON like referencing to travers an object.
[](https://travis-ci.org/willpowell8/DictionaryUtils)
[](http://cocoapods.org/pods/DictionaryUtils)
[](http://cocoapods.org/pods/DictionaryUtils)
[](http://cocoapods.org/pods/DictionaryUtils)## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
DictionaryUtils is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```swift
pod "DictionaryUtils"
```## Usage
Lets say we define an aribitary dictionary that has an arrry within it. We ideally want to be able to access properties without referencing each child object, but in a more friendly fashion.```swift
let data = ["data":["ary":[["value":1,"property1":"WELCOME"],["value":0,"property1":"WELCOME2"]]]]```
We can find the property of a child by using the the following code```swift
do {
let output = try data.readString("data.ary[0].property1")
print(output!)
}catch{
print("ERROR")
}```
This library will also let you do parameter based discovery within arrays like the below example:
```swift
do {
let output = try data.readString("data.ary[value=0].property1")
print(output!)
}catch{
print("ERROR")
}```
## Author
willpowell8
## License
DictionaryUtils is available under the MIT license. See the LICENSE file for more info.