Fastest JSON implementation written in Swift.
.package(url: "https://github.com/swiftstack/json.git", .branch("dev"))
let bytes = JSON.encode(Model())
let model = JSON.decode(Model.self, from: bytes)
let output = OutputByteStream()
JSON.encode(Model(), to: output)
let input = InputByteStream(output.bytes)
let model = JSON.decode(Model.self, from: input)
let bytes = JSONEncoder().encode(Model())
JSONEncoder().encode(Model(), to: stream)
...
public struct JSON {
public enum Value {
case null
case bool(Bool)
case number(Number)
case string(String)
case array([JSON.Value])
case object([String : JSON.Value])
public enum Number {
case int(Int)
case uint(UInt)
case double(Double)
}
}
}
{"message":"Hello, World!"}
JSON.JSONEncoder: 934 644 tasks/sec
Foundation.JSONEncoder: 92 619 tasks/sec
JSON.JSONDecoder: 236 062 tasks/sec
Foundation.JSONDecoder: 226 515 tasks/sec
{"message":"\u3053\u3093\u306B\u3061\u306F\u4E16\u754C\uFF01"}
JSON.JSONDecoder: 179 440 tasks/sec
Foundation.JSONDecoder: 88 614 tasks/sec