如何从 JSON 数据中提取国家/地区
How to pull country from JSON data
我正在使用 SwiftyJSON 库进行 JSON 解析。我没有得到国家的价值。我想要国家的价值。我想要值 "GB"。
以下是JSON:
{
"status": true,
"message": "Country Details",
"content":
{
"country": "GB"
}
}
代码:
let countryJson = response["content"]
let Country = countryJson["country"]
试试这个:
let countryJSON = response["content"] as? [String: String]
let country = countryJSON?["country"]
我正在使用 SwiftyJSON 库进行 JSON 解析。我没有得到国家的价值。我想要国家的价值。我想要值 "GB"。
以下是JSON:
{
"status": true,
"message": "Country Details",
"content":
{
"country": "GB"
}
}
代码:
let countryJson = response["content"]
let Country = countryJson["country"]
试试这个:
let countryJSON = response["content"] as? [String: String]
let country = countryJSON?["country"]