我正在使用Android Studio,並且我有一個名爲sResponse(下面)的字符串變量。根據調試器,它擁有以下值:將字符串轉換爲JSON時未終止的對象
{
"responseData": {
"emotion":"",
"lastinput":{actionResult={"value":{"label":"green","key":"1"},"result":"success","action":"displayClickableList"},
"answer":"Sorry, I did not understand.",
"link": {
"href":"",
"target":""
},
"extraData": {
},
"responseSession": {
"id":"c4a5ef257851a991eb32c69132c9",
"transaction":"4"
},
"responseDetails": "null",
"responseStatus": "200",
"applicationUrl": "http://noki-dev.cloud.com:90/moto-1/"
}
}
當我嘗試以這種方式與初始化一個JSONObject與它:
jResponse=new JSONObject(sResponse);
...以下異常升高在我logcat的:
>>>>>>>>>Thread EXCEPTION1: Response with invalid JSON format: , FrontendActivity.java L:421 ***** *org.json.JSONException: Unterminated object at character 502 of : sResponse
我懷疑那些URL在URL中造成了麻煩。我不擅長轉義JSON字符。我如何從前一個字符串獲取有效的JSONObject?我的方法可以發現什麼問題?
你有不當JSON請糾正'的ActionResult ='對象在你的JSON響應您指出的錯誤@NambiNarayanan – Nambi
感謝,價值來源於支持(也許硬編碼?)但請不要低估! – Josh
好的,我刪除了我的投票選項,但在將來發布之前請檢查您的問題。 – Nambi