Git Product home page Git Product logo

kakajson's Introduction

KakaJSON

podversion

Fast conversion between JSON and model in Swift.

Integration

CocoaPods

pod 'KakaJSON', '~> 1.0.0' 

Usages

JSON To Model

struct SCat: Convertible {
    var weight: Double = 0.0
    var name: String = ""
}

let name = "Miaomiao"
let weight = 6.66

let JSON: [String: Any] = [
    "weight": weight,
    "name": name
]

// let cat = model(from: JSON, SCat.self)
let cat = JSON.kk.model(SCat.self)

Model To JSON

struct SCar: Convertible {
    var new: Bool = true
    var age: Int = 10
    var weight: Double = 0.1234567890123456
    var height: Decimal = 0.123456789012345678901234567890123456789
    var name: String = "Bently"
    var price: NSDecimalNumber = 0.123456789012345678901234567890123456789
    var minSpeed: Double = 66.66
    var maxSpeed: NSNumber = 77.77
}

let car = SCar()
// let json = JSON(from: car)
let json = car.kk.JSON()
// let jsonString = JSONString(from: car)
let jsonString = car.kk.JSONString()

More documentation will be coming out soon....

kakajson's People

Contributors

codermjlee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.