由于此LogCat消息,我收到NullPointerException:
02-17 13:01:10.766: W/System.err(950): org.json.JSONException: Value  of type java.lang.String cannot be converted to JSONArray
02-17 13:01:10.775: W/System.err(950): at org.json.JSON.typeMismatch(JSON.java:111)
这就是我的JSON输出:
[{"rated":"1","user_id":""}]
以下是我检索它的方法:
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is2,"iso-8859-1"),8);
sb2 = new StringBuilder();
sb2.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb2.append(line + "\n");
}
is2.close();
resulttt=sb2.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
try{
jArray2 = new JSONArray(resulttt);
JSONObject json_data=null;
rateresult = new int[jArray2.length()];
rateuser = new String[jArray2.length()];
for(int i=0;i<jArray2.length();i++){
json_data = jArray2.getJSONObject(i);
rateresult[i]=json_data.getInt("rated");
rateuser[i]=json_data.getString("user_id");
}
}
知道是什么导致我的LogCat中出现“不匹配”或奇怪的值?感谢。