如何从JSON数据中提取国家/地区

时间:2018-06-11 04:28:20

标签: json swift swifty-json

我正在使用SwiftyJSON库进行JSON解析。我没有得到这个国家的价值。我想要国家的价值。我想要价值“GB”。

以下是JSON:

{
    "status": true,
    "message": "Country Details",
    "content": 
    {
        "country": "GB"
    }
}

代码:

let countryJson = response["content"]
let Country = countryJson["country"]

1 个答案:

答案 0 :(得分:0)

试试这个:

let countryJSON = response["content"] as? [String: String]
let country = countryJSON?["country"]
相关问题