martinkabat
martinkabat

Reputation: 63

Is there a data limit when using NSJSONSerialization in iOS?

I am sorry to bother you but I haven't found any usable topic that would help me.

I use NSMutableRequest through NSURLConnection to get my JSON data. Once the data are received, I serialize it using [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error].

It works just fine when getting a smaller JSON files but it doesn't work when I receive bigger JSON file. I write the log NSLog(@"--->: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); and the output is not one but two log records starting with --->:. The first output contains the first part of the JSON and the rest of JSON lays in the second one.

This error won't allow creation of NSDictionary as needed. Every "bigger" JSON received is split somewhere between 7500 - 8000 characters. My question is: Is there a limit that NSJSONSerialization can handle? From my perspective, it seems like it can handle 8 kilobytes of data and that is it. Is there any way to bypass it?

Thank you for your insights.

Upvotes: 1

Views: 924

Answers (1)

martinkabat
martinkabat

Reputation: 63

Thank you guys for your answers. I finally found the solution for my problem. The problem was in saving data badly in didReceiveData method. After applying [receivedData appendData:data]; everything starts to work well. The 8 kB problem is probably a chunk of data sent at once.

Upvotes: 1

Related Questions