开发者

JSON: how to deal with double quotations?

开发者 https://www.devze.com 2023-04-04 18:34 出处:网络
I\'m using SBJson to parse by JSON string. Some requests return somethink like this: { \"jsonResponse\":[{

I'm using SBJson to parse by JSON string. Some requests return somethink like this:

{
"jsonResponse":[{  
"id":"2",  
"name":"Somename",  
"title":"Json problem:"ErrorParsing"", //problem is here. with double quotations. how to remove them or remove error? When i delete brackets before and after ErrorParsing, it works good.  
"otherin开发者_C百科fo":"blabla",  
}]
}


Those aren’t brackets; they’re (double) quotes/quotation marks. In valid JSON, quotation marks inside strings must be escaped with \, e.g. "Hello \"World\"".

The Web service you’re using is returning invalid JSON.

http://jsonlint.com is a useful resource to validate JSON strings.


I believe you mean "double quotes," not "double brackets." You'll need to use different quotes there, so something like:

"title":"Json problem:'ErrorParsing'"


Correct json must be

{
"jsonResponse":[{  
"id":"2",  
"name":"Somename",  
"title":"Json problem:\"ErrorParsing\"", //problem is here. with double quotations. how to remove them or remove error? When i delete brackets before and after ErrorParsing, it works good.  
"otherinfo":"blabla",  
}]
}

I think you got the point

0

精彩评论

暂无评论...
验证码 换一张
取 消