我试图以JSON格式从服务器获取数据。但是这样做我在log cat中遇到错误...
01-09 15:15:35.463:E / Buffer Error(28006):转换结果出错 java.lang.NullPointerException
的0字符处
01-09 15:15:35.463:E / JSON 解析器(28006):解析数据时出错org.json.JSONException:输入结束 在
这是我的代码,
尝试{
BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj;