How to create json Object with NSData
in Objective C
. I'm having values in a NSData
variable.
You can use it like this in iOS 5 (if you are sure of your json structure you can directly use NSArray
or NSDictionary
doing a cast)
NSError *jsonError;
id jsonDictionaryOrArray = [NSJSONSerialization JSONObjectWithData:myData options:NULL error:&jsonError];
if(jsonError) {
// check the error description
NSLog(@"json error : %@", [jsonError localizedDescription]);
} else {
// use the jsonDictionaryOrArray
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With