0

I have a app that receive a feed from a server through json.

I have been building it for iOS5, but in the last weeks testing with iOS6. I tested today with a iOS5 device, and everything crashed.

The code looks like this:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.myserver.com/news.json"]];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

It worked without problems, but now it returns a null. The data is not null.

lagos
  • 1,968
  • 3
  • 17
  • 26

2 Answers2

1

Cocoa error 3840 means

The data couldn’t be read because it has been corrupted. (No string key for value in object around character 2.)

You should check your json with a validator like http://www.jsoneditoronline.org/ or http://jsonformatter.curiousconcept.com/

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
alexandresoli
  • 918
  • 1
  • 9
  • 18
0

The issue was a duplicated key from the webserver. Now it works.

But it strange that the error is trigged in iOS5 and not in iOS6.

lagos
  • 1,968
  • 3
  • 17
  • 26