pod fix
A light weight JSON Mapper.
Inspired by some JSON libraries :
According to JSONShootout, we testing the json mapping speed, and we have same performance with Marshal.
struct Sample:JSONDecodable { let temp:Int static func decode(_ dic: JSON) throws -> Sample { return try Sample(temp: dic <| "temp") } } let json = JSON(any: ["temp":1234]) let sample:Sample? = try? Sample.decode(json)
PrimitiveType focus on casting type and transform from string
Casting Type
return self as? T // return 1 as? Int // return "1" as? Int
Transform From String (String -> T)
String -> T
return Int("1") // "1" -> 1 return Int("true") // "true" -> true
Support Types
Int Int8 Int16 Int32 Int64 UInt UInt8 UInt16 UInt32 UInt64 Float Double Bool String
JSONDecodable is the protocol, mapping JSON to your customize struct.
JSON
<|?
T?
<|
T
<||
[T]
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
JSONDecodeKit
A light weight JSON Mapper.
Inspired by some JSON libraries :
According to JSONShootout, we testing the json mapping speed, and we have same performance with Marshal.
Usage
Protocols
PrimitiveType
PrimitiveType focus on casting type and transform from string
Casting Type
Transform From String (
String -> T)Support Types
JSONDecodable
JSONDecodable is the protocol, mapping
JSONto your customize struct.Operators
<|?T?<|T<||[T]