Got an error while parsing json

292 views Asked by At

I have written the code to parse the json.

NSData *getData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.xxxxxx.com/json/ajax/getArtist.json.php?songId=452"]] returningResponse:nil error:&error1];
BOOL isTurnableToJSON = [NSJSONSerialization isValidJSONObject: getData];
NSLog(@"isTurnableToJSON: %d", isTurnableToJSON);

id  jsonData = [NSJSONSerialization JSONObjectWithData:getData options:NSJSONReadingAllowFragments error:&error];
NSLog(@"Data===%@",jsonData);
NSLog(@"Error===%@",error);

and get error

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0xa8dd6b0 {NSDebugDescription=Invalid value around character 0.}

and json response

{"trackDetails":[{"trackTitle":"Faghat Be Eshghe To","artist":"Babak Jahanbakhsh","albumName":"Oxygen","likes":"0","loves":"0","albumImage":"http:\/\/www.xxxxxxx.com\/files\/albums\/audio\/thumbs\/105x105\/a6f69b486abc27e13f2c23c9283da606.jpg","url":"http:\/\/www.xxxxxx.com\/files\/music\/446\/aafe6fff1f8d9313e560dce0eeb70e37.mp3","finishTime":"838"}]}

I have check the json in http://jsonlint.com/ this site response is valid json Plz help

0

There are 0 answers