我有这部分代码(请注意,它responseBody
确实来自网络服务器)。
public JSONObject getObj(){
String responseBody = '[{"zip":"56601","city":"Bemidji","state":"MN","county":"Beltrami","dist":"0.14802"},{"zip":"56619","city":"Bemidji","state":"MN","county":"Beltrami","dist":"3.98172"}]';
JSONObject response = null;
try{
response = new JSONObject(responseBody);
}catch(JSONException ex){
Logger.getLogger(Http.class.getName()).log(Level.SEVERE, null, ex);
}
return response;
}
我不明白为什么 JSONObject 会抛出异常。是什么让它这样做?