JSON.parse in nodejs code example
Example 1: javascript parse json
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson);
Example 2: json parse returns object
var str = '[{"UserName":"xxx","Rolename":"yyy"}]';
var parsed = JSON.parse(str);
var user = parsed[0];
console.log(user.UserName);
console.log(user.Rolename);
Example 3: js string to json
var obj = JSON.parse("{no:'u',my:'sql'}");
Example 4: parse string javascript
parseFloat("16.5");
parseInt("34.6");
JSON.parse('{ "name":"John", "age":30, "city":"New York"}');