Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 1.87 KB

README.md

File metadata and controls

63 lines (42 loc) · 1.87 KB

alt text

DictionaryUtils

Dictionary utils allows you to use JSON like referencing to travers an object.

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

DictionaryUtils is available through CocoaPods. To install it, simply add the following line to your Podfile:

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.

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")
}

Author

willpowell8

License

DictionaryUtils is available under the MIT license. See the LICENSE file for more info.