0

I'm now parsing with NSJSONSerialization

NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"url"]];
NSError *jsonError = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&jsonError];


NSDictionary *jsonDictionary = (NSDictionary *)jsonObject;

[self setTableData:jsonDictionary];

But it won't parse my JSON because of special characters in the JSON like the letter 'ü' when i remove the 'ü' from the JSON it's working correclty. I tried the code above and:

options:utf8...

Does anyone know how i can fix this?

IluTov
  • 6,807
  • 6
  • 41
  • 103
Frenck
  • 6,514
  • 5
  • 22
  • 25
  • Your string is improperly encoded/converted. If properly encoded and the UTF8 gets converted to Unicode then JSON will have no problem. – Hot Licks Dec 24 '12 at 22:21

2 Answers2

0

Try to change NSJSONReadingMutableContainers with NSJSONReadingMutableLeaves. This solved me similar problem.

Misha
  • 5,260
  • 6
  • 35
  • 63
  • Can you verify that your data is in UTF-8 format? If not, convert it first before calling NSJSONSerialization – Misha Dec 24 '12 at 15:30
  • @Frenck -- Read the data into an NSString before JSON decoding and see what you get. – Hot Licks Dec 24 '12 at 22:23
0

Try using NSString with which you can explicitly specify encoding. Ex:

NSString *string = [NSString stringWithContentsOfURL:webURL encoding:NSUTF8StringEncoding error:&error];

You can then convert the NSString object to NSData and then do the JSON serialisation..

Anurag Kapur
  • 675
  • 4
  • 19