简体   繁体   English

解析JSON数据时出错

[英]Error in parsing json data

I have this json data.I want to parse it.I am getting error when I am trying to do 我有这个json数据。我想解析它。尝试执行时遇到错误

JsonObject json=new JsonObject(x);

Because it contains white spaces. 因为它包含空格。

{id=11, note=A sample note,}

Please help me to solve it. 请帮我解决。

To make your example a valid JSON wrap the properties and values in double quotes, remove the last comma and replace your equal sign with colon. 为了使示例成为有效的JSON,请将属性和值用双引号引起来,请删除最后一个逗号,并用冒号替换等号。

The result will look like this: 结果将如下所示:

{
    "id": "11",
    "note": "A sample note"
}

You Have to keep in mind two things: 您必须记住两件事:

1) Check If The JSON Format Is Right: 1)检查JSON格式是否正确:

The JSON Format Of your Data Should Be like This . JSON格式您的数据应该像这样

2) Check That Your Code is Correct: 2)检查您的代码是否正确:

Visit This Website for Code. 访问此网站获取代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM