JSON.parse returning [Object Object] instead of value

Consider the following:

    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

You have an array. Then need to get 0th element very first

This will work

let unps =  JSON.parse('[{"UserName":"xxx","Rolename":"yyy"}]')[0]
console.log(unps.UserName, unps.Rolename);

If your data is a string then you need to parse it with JSON.parse() otherwise you don't need to, you simply access it as is.

// if data is not in string format
const data = [{"UserName":"xxx","Rolename":"yyy"}];

const username = data[0].UserName
const rolename = data[0].Rolename

console.log(username)
console.log(rolename)

// if data is in string format
const strData = JSON.parse('[{"UserName":"xxx","Rolename":"yyy"}]');

const Username = strData[0].UserName
const Rolename = strData[0].Rolename

console.log(Username)
console.log(Rolename)