Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.json.JSONException: Unterminated object at character 103 of

Tags:

java

json

android

i don't know why this strings contert to Json have error.

{
  softName: lovePlay,
  packageName: com.feng.play,
  softId:13232,
  downUrl: http.//mumayi.pay.love/down?id=13211
}

Have somebody can help me? thanks.

like image 271
cnFeng Avatar asked Mar 28 '13 10:03

cnFeng


3 Answers

Strings should be under double quotes. Something like this:

{
   "softName":"lovePlay",
   "packageName":"com.feng.play",
   "softId":13232,
   "downUrl":"http.//mumayi.pay.love/down?id=13211"
}

There are many services on the internet where you be able to validate your json data. Click here

like image 134
endian Avatar answered Oct 19 '22 08:10

endian


Your JSON string is incorrect, you're missing the quote signs (").

Try this:

{
    "softName": "lovePlay",
    "packageName": "com.feng.play",
    "softId": "13232",
    "downUrl": "http.//mumayi.pay.love/down?id=13211"
}
like image 3
flash Avatar answered Oct 19 '22 07:10

flash


Thanks all. I have solved this problem. When I use this:

<!-- white space added for readability -->
<input type="button" onclick="getp1('{softName:lovePlay
             ,packageName:com.feng.play
             ,softId:13232
             ,downUrl:\'http\:\/\/mumayi.pay.love\/down\?id=13211\'}')" 
            value="获取"/>   

I can get strings convert to json. I use it by webview.

like image 1
cnFeng Avatar answered Oct 19 '22 08:10

cnFeng