I am parsing a json which is faulty. I am doing this in Swift like this:
jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
So, it gives an error.
Error converting string to object => Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Badly formed object around character 11396.) UserInfo=0x14512990 {NSDebugDescription=Badly formed object around character 11396.})
Now, the response is a huge one, so I am posting only the error part of it:
{
"data" : {
"operator_settings" : {
"profileSettings" : "{"visible":["firstname","lastname","phonenumber","emailaddress","paddress","paddress2","paddresscity","paddressstateabbreviation","paddresszip","paddresscountry"],"required":["firstname","lastname","emailaddress","paddress","paddresscity","paddresszip"]}"
}
},
"status" : 200.0,
"count" : null
}
Also, I want to make this response like this before parsing it:
{
"data": {
"operator_settings": {
"profileSettings": "{\"visible\":[\"firstname\",\"lastname\",\"phonenumber\",\"emailaddress\",\"paddress\",\"paddress2\",\"paddresscity\",\"paddressstateabbreviation\",\"paddresszip\",\"paddresscountry\"],\"required\":[\"firstname\",\"lastname\",\"emailaddress\",\"paddress\",\"paddresscity\",\"paddresszip\"]}"
}
},
"status": 200,
"count": null
}
But, I do not know the depth of the response. I do not have access to the API which I am calling. So, is there a solution that I can do?