Deserialize JSON / NSDictionary to Swift objects

前端 未结 13 1559
情歌与酒
情歌与酒 2020-11-29 18:43

Is there a way to properly deserialize a JSON response to Swift objects resp. using DTOs as containers for fixed JSON APIs?

Something similar to http://james.newtonk

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 19:08

    Yet another JSON handler I wrote:

    • https://github.com/dankogai/swift-json

    With it you can go like this:

    let obj:[String:AnyObject] = [
        "array": [JSON.null, false, 0, "", [], [:]],
        "object":[
            "null":   JSON.null,
            "bool":   true,
            "int":    42,
            "double": 3.141592653589793,
            "string": "a α\t弾\n

提交回复
热议问题