【发布时间】:2014-02-23 10:03:49
【问题描述】:
我正在尝试解析这个相对简单的 JSON 数组:
{
"tags":[
"Cheese",
"Milk",
"Yoghurt"
],
"success":1,
"message":"Tags found"
}
我得到的是这样的:
Log.d("Tag products: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt("success");
if (success == 1) {
// products found
// Getting Array of Products
JSONArray products = json.getJSONArray("tags");
} else {
// no products found
}
} catch (JSONException e) {
e.printStackTrace();
}
我的数组完美地记录到我的 logcat 中。我成功地检索了成功和消息的价值。但我无法解析实际的标签。
大多数关于 json 解析的示例和教程都使用了另一种格式,所以我也会非常高兴有一个示例来演示这种数组的解析。
【问题讨论】:
标签: android arrays json parsing