I know a lot of questions have addressed this issue but I have not found one that helped me...
When I parse json data downloaded from a localhost (MAMP server), I face the json error 3840 stating invalid value around character 0...
I don't understand why, since my php script with a var_dump on my array displays (an array of array):
array(2) { [0]=> array(5) { ["ID"]=> string(1) "1" ["EDS"]=> string(4) "1000" ["lastname"]=> string(8) "My lastname" ["firstname"]=> string(9) "My firstname" ["dateOfBirth"]=> string(10) "19.12.1975" } [1]=> array(5) { ["ID"]=> string(1) "2" ["EDS"]=> string(4) "1001" ["lastname"]=> string(14) "Smith" ["firstname"]=> string(6) "John" ["dateOfBirth"]=> string(10) "11.11.1111" } }
...which for me seems to be a valid json array.
When I log the NSMutableData downloaded, it is not null, but something like
76353648 2734b0a9 (+ around fifty like this).
I don't know if it is because the data is not complete, but I don't know how I can keep on analyzing a little further what is going wrong.
If anyone has an idea of what happens (I understand it has to do with a special character not recognized), it would be great.
Thanks a lot!
Edit: Added followup code to the original question:
In
(void)connectionDidFinishLoading:(NSURLConnection *)connection {
id jsonObject = [NSJSONSerialization JSONObjectWithData:_downloadedData options:NSJSONReadingAllowFragments error:&error];
if ([jsonObject isKindOfClass:[NSArray class]]) {
NSArray *deserializedArray = (NSArray *)jsonObject;
for (NSDictionary *jsonElement in deserializedArray)
{
Person *newPersonElement = [[PersonStore sharedStore] createPerson]; // --> what makes the app crash. But this method is working everywhere else...
// more code omitted
}
I don't know why this initialization crashes here...