【发布时间】:2017-10-05 16:01:54
【问题描述】:
[Data]: 10633 bytes
[Result]: SUCCESS: {
branded = (
{
"brand_name" = "Pal's Sudden Service";
"brand_name_item_name" = "Pal's Sudden Service Hotdog";
"brand_type" = 1;
"food_name" = Hotdog;
"nf_calories" = 300;
"nix_brand_id" = 58769799a5bb96105b8fb337;
"nix_item_id" = c6402707666e81250cff44d4;
photo = {
highres = "<null>";
thumb = "https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png";
我正在尝试解析此 JSON 数据,但我很挣扎。例如,当我简单地拨打json["branded"]["brand_name"] 时,我什么也没有收到。
如何绕过顶层的括号并获取数据?
我正在使用 SwiftyJSON 来解析数据,这就是为什么它的格式与我的示例一样。
【问题讨论】:
-
调试:
json["branded"]nil?如果不是,json["branded"]似乎是一个数组,而不是字典。所以json["branded"][0]["brand_name"]? -
非常感谢,我没有意识到 () 是一个数组。
标签: json swift api swift3 swifty-json