解析 JSON 文件时遇到“解析数据错误”错误
解析以下文本时,解析器似乎适用于这些:
{"vid":"2",
"uid":"1",
"title":"BangsarSouth",
"log":"",
"status":"1",
"comment":"1",
"promote":"0",
"sticky":"0",
"nid":"2",
"type":"property",
"language":"und",
"created":"1369825923",
"changed":"1370534102",
"tnid":"0"
但是一旦它到达文件的这一部分,它就会崩溃并给我一个解析错误
"body":{"und":[{"value":"Some description for Bangsar South.\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.","summary":"","format":"filtered_html","safe_value":"<p>Some description for Bangsar South.<br />\nLorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
ETC ...
我怀疑错误是由于嵌套元素造成的。有人可以为我的问题提出解决方案吗?
下面是我的javacode
try {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://xxxxxx.com/rest/node/2.json");
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection "+e.toString());
}
try {
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();
result=sb.toString();
Log.e("faridi",result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result "+e.toString());
}
//parse json data
try{
jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
}
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
}