Latest4.1.0
Homepagehttps://github.com/yume190/JSONDecodeKit
LicenseMIT
Platformsios 9.0, osx 10.9, tvos 9.0, watchos 2.0
Authors

Build Status
codecov
codebeat badge

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

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)

Protocols

PrimitiveType

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)

    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

JSONDecodable is the protocol, mapping JSON to your customize struct.


Operators

OperatorDecode element
<|?T?
<|T
<||[T]

Latest podspec

{
    "name": "JSONDecodeKit",
    "version": "4.1.0",
    "license": "MIT",
    "summary": "A Light weight JSON Mapper",
    "homepage": "https://github.com/yume190/JSONDecodeKit",
    "authors": {
        "yume190": "[email protected]"
    },
    "social_media_url": "https://www.facebook.com/yume190",
    "source": {
        "git": "https://github.com/yume190/JSONDecodeKit.git",
        "tag": "4.1.0"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.9",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source_files": [
        "Sources/JSONDecodeKit/*.swift",
        "Sources/JSONDecodeKit/JSON/*.swift"
    ],
    "swift_version": "4.1",
    "static_framework": true
}

Pin It on Pinterest

Share This