Search code examples
iphoneiosutf-8touchjson

TouchJSON - Why I get lots of \U**** in the results of parsing?


I am using TouchJSON to parse a JSON data.

In the results, the strings in the array are all in \U** format.

Yes, they are meant to be other languages than English.

Why TouchJSON can't just replace them with real string via UTF8?

How should I deal with the results if I want to store them as NSStrings and use them in UILabel?

Thanks


Solution

  • The leading \u should not be a part of the string, but rather an identifier. If you load an NSString from parsed NSDictionary, it should've ignored the leading \u.

    If it did not, you can always use [theString substringFromIndex: 2] to remove any leading identifiers.

    Otherwise, take a look at SBJson, an alternative library for Objective-C JSON parsing.