Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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 NullPointerException解析JSON对象_Java_Php_Blackberry - Fatal编程技术网

Java NullPointerException解析JSON对象

Java NullPointerException解析JSON对象,java,php,blackberry,Java,Php,Blackberry,我从下面的代码中得到一个异常: int[] startApps; JSONObject jsonObjectMapData=new JSONObject(result); JSONArray jsonaryPlaceMark = jsonObjectMapData.getJSONArray("Apps"); JSONObject apps= jsonaryPlaceMark.getJSONObject(0); int indx=0; startApps[indx++]=Integer.

我从下面的代码中得到一个异常:

int[] startApps;
JSONObject jsonObjectMapData=new JSONObject(result); 
JSONArray jsonaryPlaceMark = jsonObjectMapData.getJSONArray("Apps"); 
JSONObject apps=   jsonaryPlaceMark.getJSONObject(0); int indx=0; 
startApps[indx++]=Integer.parseInt(apps.getString("Thread1")); 
startApps[indx++]=Integer.parseInt(apps.getString("Thread2"));
我在第行得到java.lang.NullPointerException:

          startApps[indx++]=Integer.parseInt(apps.getString("Thread1")); 
服务器响应:

{
 "name": "10.000000,106.000000",
"Status": {
"code": 200,
"request": "geocode"
},
"Apps": [ {
"Thread1": 1,
"Thread2": 1,   
"Thread3": 1,
"Thread4": 1,
"Thread5": 1,
"Thread6": 1,
"Thread7": 1
} ]
}

您没有初始化数组

尝试:

或者一步到位:

int[] startApps = int[10];

您没有初始化数组

尝试:

或者一步到位:

int[] startApps = int[10];

显示json字符串?什么是
startApps
?显示json字符串?什么是
startApps
?它没有在您显示的代码中声明。