![](/img/trans.png)
[英]org.json.JSONException: Value of Feedback type java.lang.String cannot be converted to JSONArray while converting jsonstring to object
[英]converting jsonstring to java object
我正在嘗試將 Json 字符串轉換為 Java 對象。 它適用於其他輸入,僅適用於一個輸入,但它不起作用。 他們還有其他方法可以做到這一點嗎?
我的代碼:
JsonParser parser=new JsonParser();
JsonObject sel=parser.parse(selectedTerritory).getAsJsonObject();
TmsMapItBuilderBean dataSet = new Gson().fromJson(sel, TmsMapItBuilderBean.class);
ArrayList dataList = dataSet.getResultList();
resultMapData = mapServiceDelegate.processAssetDataWithGeoCodeForTerritories(subId, dataList);
它顯示以下錯誤:
Error on json convert to object :com.google.gson.JsonSyntaxException:
com.google.gson.stream.MalformedJsonException: Unterminated object near
ddress' :'2500 LEE'S CHAPEL RD', "stat
您的 JSON 已損壞。 您使用一個字符來分隔您用來編碼對象的字段。 使用轉義符將 ' 編碼為字符串。
示例: { 'name': 'tom\\'s Hut' }
然而,正如有人指出的 ' 不打算用於 JSON 對象。 我強烈建議您使用雙引號。
{"name": "tom's Hut"}
會是正確的方法...
有關 JSON 的更多信息,請參見: http : //www.json.org/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.