Yet another Swift JSON encoder/decoder. Intended to be RFC7159 compliant.
import PackageDescription
let package = Package(
name: "hello",
dependencies: [
.Package(url: "https://github.com/rintaro/Swift-JSON.git", majorVersion: 0, minor: 2),
]
)
github "rintaro/swift-JSON" ~> 0.2
(a.k.a. parse or deserialize)
import JSON
let jsonData: Data = ...
do {
let value = try JSON.decode(jsonData)
// do something...
} catch let e as JSONParsingError {
print(e)
}
(a.k.a. dump or serialize)
import JSON
let value: Any = ...
do {
let data = try JSON.encode(value)
// do something...
} catch let e as JSONPrintingError {
print(e)
}
- Swift 3.0.1 (Xcode8.1 on macOS)
- Foundation