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
?它没有在您显示的代码中声明。