Org.json.JSONException:字符1834处未终止的字符串
我从Web服务中获取数据,我将其解析为JSON字符串。 解析时,我是这个异常:“org.json.JSONException:在字符1834未终止的字符串”
我的代码是,
String jsonstring=getJSONString(response);
JSONObject json = new JSONObject(jsonstring);
字符串是,
[{"LotDescription":"David Weekley homes Traditional Collection in Baxter Village offers floor plans featuring innovative design and unsurpassed quality. This charming community combines work, play and living, all within the Village. In Baxter Village, you’ll enjoy: Parks, playgrounds"}]
它解析到“村庄”一词,并在解析“你会”时引发异常,这似乎是一些HTML内容。
这是什么解决方案?
你需要添加字符 。
[{"LotDescription":"David Weekley homes Traditional Collection in Baxter Village offers floor plans featuring innovative design and unsurpassed quality. This charming community combines work, play and living, all within the Village. In Baxter Village, you’ll enjoy: Parks, playgrounds"}]
这会做。
你的Json不是JSONObject
而是JSONArray
。
试试这个:
JSONArray jObject = new JSONArray(jsonstring);
for (int i = 0; i < jObject.length(); i++) {
JSONObject object = jObject.getJSONObject(i);
String LotDescription = menuObject.getString("LotDescription");
}
链接地址: http://www.djcxy.com/p/71611.html
上一篇: Org.json.JSONException: Unterminated string at character 1834
下一篇: Referring shared Java EE library for EAR application in weblogic