【发布时间】:2016-09-29 08:01:23
【问题描述】:
我的基本 JSON 数据结构是这样的:
[
{
"data1":"contents of data1",
"data2":"contents of data 2"
},
{
"data1":"contents of data1",
"data2":"contents of data 2"
}
]
我尝试使用JSONArray myJson = new JSONArray(json);
但它给了我:
org.json.JSONException:不是原始数组:类 org.json.JSONObject
我正在通过以下方式检索 JSON:
JSONParser jParser = new JSONParser();
// Getting JSON from URL
JSONObject json = jParser.getJSONFromUrl(url);
并使用 JSONArray myJson = new JSONArray(json); 将其转换为 JSONArray
谢谢!
【问题讨论】: