Parse json in Swift, AnyObject type

后端 未结 3 2026
北荒
北荒 2020-12-05 02:02

I\'m trying to parse a json but I have some difficulties with the data types and notably the AnyObject type + downcasting.

Let\'s consider the following json (it\'s

3条回答
  •  醉梦人生
    2020-12-05 02:39

    Try:

    • 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

提交回复
热议问题