Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';t提取JSON数据_Java_Android_Json - Fatal编程技术网

Java Can';t提取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

大家好,我对JSON有问题

   {  
     "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库
但不能这样做。
为什么?什么是问题?