A pure-Swift JSON parser and serializer
import class JsonSerializer.JsonParser
import enum JsonSerializer.Json
// parse a JSON data
let data: NSData
switch JsonParser.parse(data) {
case .Success(let json):
println(json["foo"]["bar"].stringValue)
case .Error(let error):
println(error)
}
// build a JSON structure
let profile: Json = [
"name": "Swift",
"started": 2014,
"keywords": ["OOP", "functional programming", "static types", "iOS"],
]
println(profile.description) // packed JSON string
println(profile.debugDescription) // pretty JSON string
Swift-JsonSerializer is a JSON serializer and deserializer which are implemented in pure Swift and adds nothing to built-in / standard classes in Swift.
- This library doesn't work with optimization flags (
swiftc -O
) as of Xcode 6.1.1 / Swift version 1.1 (swift-600.0.56.1).
Fuji, Goro (gfx) [email protected]
The Apache 2.0 License