Org.json.JSONException:字符1834处的未终止字符串

时间:2013-05-21 07:05:14

标签: java android json

我从webservice获取数据,我正在解析为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"}]

它正在解析直到单词“Village”并在解析“you'”时提出异常,这似乎是一些HTML内容。

这是什么解决方案?

2 个答案:

答案 0 :(得分:3)

您需要添加字符\

[{"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\"}]

这样做。

答案 1 :(得分:1)

你的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");
         }