Dictionary utils allows you to use JSON like referencing to travers an object.
To run the example project, clone the repo, and run pod install
from the Example directory first.
DictionaryUtils is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DictionaryUtils"
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.
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
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:
do {
let output = try data.readString("data.ary[value=0].property1")
print(output!)
}catch{
print("ERROR")
}
willpowell8
DictionaryUtils is available under the MIT license. See the LICENSE file for more info.