Jay-C7
July 26, 2016 ยท View on GitHub
If you want to use C7.JSON type with Jay in your project, just use this package, which automatically includes the appripriate Jay version.
Usage
Parsing from data (deserialization)
do {
//get data from disk/network
let data: [UInt8] = ...
//ask Jay to parse your data
let json = try Jay().c7jsonFromData(data) // C7.JSON
//if it doesn't throw an error, all went well
if let tasks = json.dictionary?["today"]?.array {
//you have a dictionary root object, with an array under the key "today"
print(tasks) //["laundry", "cook dinner for gf"]
}
} catch {
print("Parsing error: \(error)")
}
Formatting into data (serialization)
do {
let json: JSON = ... // C7.JSON
let data = try Jay(formatting: .prettified).dataFromC7Json(json: json) // [UInt8]
//send data over network, save to disk
} catch {
print("Formatting error: \(error)")
}
Installation
Swift Package Manager
.Package(url: "https://github.com/czechboy0/Jay-C7.git", majorVersion: 0, minor: 16)
:gift_heart: Contributing
Please create an issue with a description of your problem or open a pull request with a fix.
:v: License
MIT
:alien: Author
Honza Dvorsky - http://honzadvorsky.com, @czechboy0