1var jsonPerson = '{"first_name":"billy", "age":23}';
2var personObject = JSON.parse(jsonPerson); //parse json string into JS object
1 var str = '[{"UserName":"xxx","Rolename":"yyy"}]'; // your response in a string
2 var parsed = JSON.parse(str); // an *array* that contains the user
3 var user = parsed[0]; // a simple user
4 console.log(user.UserName); // you'll get xxx
5 console.log(user.Rolename); // you'll get yyy
1<!DOCTYPE html>
2<html>
3<body>
4<h2>Convert a string into a date object.</h2>
5<p id="demo"></p>
6<script>
7var text = '{"name":"John", "birth":"1986-12-14", "city":"New York"}';
8var obj = JSON.parse(text);
9obj.birth = new Date(obj.birth);
10document.getElementById("demo").innerHTML = obj.name + ", " + obj.birth;
11</script>
12</body>
13</html>
14