java org.json.JSONException: 字符 103 处的未终止对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15679123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
org.json.JSONException: Unterminated object at character 103 of
提问by cnFeng
i don't know why this strings contert to Json have error.
我不知道为什么这个字符串 contert to Json 有错误。
{
softName: lovePlay,
packageName: com.feng.play,
softId:13232,
downUrl: http.//mumayi.pay.love/down?id=13211
}
Have somebody can help me? thanks.
有人可以帮助我吗?谢谢。
回答by endian
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
互联网上有许多服务可以验证您的 json 数据。点击这里
回答by flash
Your JSON
string is incorrect, you're missing the quote signs ("
).
您的JSON
字符串不正确,您缺少引号 ( "
)。
Try this:
试试这个:
{
"softName": "lovePlay",
"packageName": "com.feng.play",
"softId": "13232",
"downUrl": "http.//mumayi.pay.love/down?id=13211"
}
回答by Jay Mayu
You have syntax error in your JSON string. You need to change it as below.
您的 JSON 字符串中有语法错误。你需要改变它如下。
{
"softName": "lovePlay",
"packageName": "com.feng.play",
"softId": "13232",
"downUrl": "http.//mumayi.pay.love/down?id=13211"
}
If you are on web dev environment you can use stringify command. Check out this tutorial on JSON and Java
如果您在 Web 开发环境中,则可以使用 stringify 命令。查看有关JSON 和 Java 的本教程
As a good practice, check whether your JSON is valid. There are many tools available but JSONlintis my favourite.
作为一个好习惯,检查您的 JSON 是否有效。有很多可用的工具,但JSONlint是我的最爱。
回答by cnFeng
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.
我可以将字符串转换为 json。我通过 webview 使用它。
回答by Zin Win Htet
This is my method currently using
这是我目前使用的方法
public String convertStandardJSONString(String data_json){
data_json = data_json.replace("\", "");
data_json = data_json.replace("\"{", "{");
data_json = data_json.replace("}\",", "},");
data_json = data_json.replace("}\"", "}");
return data_json;
}