NSURLConnection : JSON text did not start with array or object and option to allow fragments not set
Set option value to NSJSONReadingAllowFragments
instead of kNilOptions
I have tested your JSON taking it in a local file
id json = [NSJSONSerialization JSONObjectWithData:contentOfLocalFile options:NSJSONReadingAllowFragments error:&deserializingError];
NSLog the actual data that you are getting, not the string, and check the first bytes. JSONSerializer didn't find a { or a [ as the first character, so you probably have some zero bytes, or byte order marks, or some other invisible characters like that.
In addtion to Janmenjaya's answer i would like to add:-
I have faced this issue twice in different API's. The problem each time that i had was
- First time the response that i was receiving was not in correct format. Remember the format must always start with a "[" or "{". So that was corrected from backend.
- Secondly , i was trying to hit an URL which had a word "video" in it for ex http://www.xyz/video123.com and websites related to name video have been blocked in our office. Therefore ensure that the network that you are using has no such restrictions.Postman will show you correct response but in devices or simulators you will face issues.
Please ensure these cases also.