📜  json 解析返回对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:02.150000             🧑  作者: Mango

代码示例2
var str = '[{"UserName":"xxx","Rolename":"yyy"}]'; // your response in a string
    var parsed = JSON.parse(str); // an *array* that contains the user
    var user = parsed[0];         // a simple user
    console.log(user.UserName);   // you'll get xxx
    console.log(user.Rolename);   // you'll get yyy