A lightweight and small JSON parser for Swift.
Based on "Dynamic Member Lookup" Types.Learn more here Introduce User-defined "Dynamic Member Lookup" Types.
let string = "{\"id\": 923, \"name\": \"hello\", \"coord\":{\"lon\": 116.4, \"lat\": 39.91}}"
let json = JSON.parse(string)
let id = json.id.intValue // 923
let name: String = json.name // hello
let lon: Double = json.coord.lon // 116.4
- Swift 4.2 or later
- Insert
github "chn-lyzhi/SmallJSONParser"
to your Cartfile. - Run
carthage update
. - Link your app with
SmallJSONParser.framework
inCarthage/Build
.
(coming soon)
- Insert
pod 'SmallJSONParser'
to your Podfile. - Run
pod install
.