Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
JSONParser-iOS
JSONParser-test
JSONParser.xcodeproj
JSONParser
.gitignore
Cartfile
Cartfile.resolved
JSONParser.framework.zip
README.md

README.md

JSONParser

A wrapper for SwiftyJSON that adds support for dynamic member lookups in swift 4.2.

How to use

JSONParser takes either a JSON object, a string, or a Data object containing JSON.

It turns this:

json["users"][0]["name"].string

Into this

json.users[0].name.value

Example

Here is an example from the test target:

import JSONParser

let testString = """
{
    "name":"John",
    "age":30,
    "cars": {
        "car1":"Ford",
        "car2":"BMW",
        "car3":"Fiat"
    }
}
"""

do {
    let json = try JSONParser(parseString: testString)
    
    print(json.cars.car2.value!) // BMW
} catch _ { }

Disclamer

JSONParser relies on @dynamicMemberLookup which is only available in swift 4.2.

Install

You can use carthage to install this framework:

github "pudility/JSONParser"
You can’t perform that action at this time.