xxxxxxxxxx
NSData *data = [yourString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
// OR
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"string: %@",json);
xxxxxxxxxx
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
xxxxxxxxxx
//JSON.parse()
const json = "{\"name\": \"Example\", \"age\": 50}";
let parsed_json = JSON.parse(json);
console.log(`Name: ${parsed_json.name}; Age: ${parsed_json.age}`)
// Returns "Name: Example; Age: 50"
xxxxxxxxxx
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.