【发布时间】:2015-04-22 11:08:30
【问题描述】:
我在我的代码中使用JSON 解析。我尝试了很多,但无法弄清楚出了什么问题。
这是我的JSON 回复
[{
"order": {
"transaction_id": "bFnRjTPYfD",
"status": 0,
"created_at": "2015-04-22 09:35:35"
}
}, {
"order_items": [{
"item_id": 1,
"item_name": "Potato",
"item_description": null,
"item_salesprice": 14,
"item_imagepath": "\/uploads\/veggies\/potato.jpg",
"order_quantity": "4 Kg",
"order_price": 69.99
}, {
"item_id": 2,
"item_name": "Tomato",
"item_description": null,
"item_salesprice": 18,
"item_imagepath": "\/uploads\/veggies\/tomato.jpg",
"order_quantity": "6 Kg",
"order_price": 79.99
}]
}]
我想提取交易 ID 和项目名称。你能帮我解决这个问题吗?
更新答案:
NSDictionary *Order=[JSONData ValueForKey:@"Order"];
NSString *transaction_id=[Order ValueForKey:@"Transaction_id"];
【问题讨论】:
-
很高兴看到你的一些尝试,这样我们可以更好地帮助你。
-
@user3659166 请试试我的回答。
-
请尝试一下,然后发布您的问题。而不是发布 JSON 日志并要求其他人解析 JSON..!
-
您作为答案添加的代码将崩溃。
-
@user3659166 嘿......每个人都想帮助你,所以你为什么不接受任何答案。如果您对答案不满意,请告诉我。会更新的。
标签: ios objective-c json nsstring nsdictionary