I am using objective C JSON parsing library and facing some issue . My web service returns the JSON response . My Parser fails when there is an escape character in the response string . Below is the response I am receiving from the server .
Now if you observer the line
“item_name” : “Spend$10andget$24worthofdonutsfromJim\’sDonutShop” , there is an escape character Jim\s Donut . My Parser fails to parse this with the exception.
-JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=8 \"Illegal escape sequence '0x27'\" UserInfo=0x79cc420 {NSLocalizedDescription=Illegal escape sequence '0x27'}",
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: item_name\" UserInfo=0x79cc510 {NSUnderlyingError=0x79cc470 \"Illegal escape sequence '0x27'\", NSLocalizedDescription=Object value expected for key: item_name}",
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: parameters\" UserInfo=0x79cc5c0 {NSUnderlyingError=0x79cc540 \"Object value expected for key: item_name\", NSLocalizedDescription=Object value expected for key: parameters}"
All I am using is JSON.h
NSDictionary * responseDic = [responseString JSONValue];
Somebody please help me !! Thank you !!
The escape sequence
\'is not valid JSON. See json.org.You should raise a bug with the maintainers of the web service.
As a work around, you might try replacing the sequence with a single
'e.g.