Java Can';t提取JSON数据
大家好,我对JSON有问题Java Can';t提取JSON数据,java,android,json,Java,Android,Json,大家好,我对JSON有问题 { "browseResults":[ { "id": "Simulation Examples.Functions.Random1" }, { "id": "Simulation Examples.Functions.Random2" }, { "id": "Simulation Examples.Funct
{
"browseResults":[
{
"id": "Simulation Examples.Functions.Random1"
},
{
"id": "Simulation Examples.Functions.Random2"
},
{
"id": "Simulation Examples.Functions.Random3"
},
{
"id":"Simulation Examples.Functions.Random4"
}
],
"succeeded": true,
"reason": ""
}
我想使用这部分代码,但做不到。
我可以用什么来代替它
JSONObject jsonObject=new JSONObject(result);
String main = jsonObject.getString("browseResults");
Log.i("Content2",main);
JSON
解析将是:
JSONObject jsonObj = new JSONObject(result);
JSONArray bResults = jsonObj.getJSONArray("browseResults");
for (int i = 0; i < bResults.length(); i++)
{
JSONObject c = bResults.getJSONObject(i);
String id = c.getString("id");
Log.i("Content2",id);
}
JSONObject jsonObj=新的JSONObject(结果);
JSONArray bResults=jsonObj.getJSONArray(“浏览器结果”);
对于(int i=0;i
尝试以下代码来解析数据:
JSONObject jsonObject = new JSONObject(result);
try {
JSONArray jsonArray = jsonObject.getJSONArray("browseResults");
for(int i = 0 ; i < jsonArray.length() ; i++)
{
JSONObject id = jsonArray.getJSONObject(i);
}
} catch (JSONException e1) {
e1.printStackTrace();
}
Log.i("Content2",jsonObject);
JSONObject JSONObject=新的JSONObject(结果);
试一试{
JSONArray JSONArray=jsonObject.getJSONArray(“浏览器结果”);
for(int i=0;i
使用GSON库但不能这样做。
为什么?什么是问题?