Search code examples
iphonejsonparsingtouchjson

TouchXML parse response with unquoted keys


Is there a way to use TouchXML to parse json in which the key are not quoted, like this:

{ foo:"bar" }

I'm trying to parse the response from a webservice (google), so simply fixing the JSON code to be valid is not an option.

If it's not possible, is there a way to efficiently quote the keys as a preprocessing step?


Solution

  • I decided to pre-parse it with RegexKitLite, using

    uint numReplace = [encoded replaceOccurrencesOfRegex:@"(?<=[\\{,])[^:\\[\\{\"]+(?=:)" withString:@"\"$0\""];