I want to convert JSON response data into an array. Pass the data using json.stringify() method and get the response in JSON format. But I want to convert this response into an array. My code is,
$.ajax({
url: "url/json/Login",
type: "POST",
data: JSON.stringify({
accountID: "ymmsansdu",
userID: "ymmascnuelas",
password: "ymma23@123"
}),
contentType: "application/json; charset=utf-8",
success: function (data) {
var response = JSON.stringify(data);
alert(response);
},
});
The response of this code:
{"LoginResult":{"ErrorCode":0,"StatusMessage":"Success","UserInfo":{"AccountID":"dfdgfgh","Description"
:"description Cabs","EmailID":"","Name":"","PhoneNumber":"","UserID":"asxdsvdgfbg"}}}
I want to get userInfo into an array.
Please help me.
alert()is actually what's showing the"[object Object]"as it simply converts the value.toString(). And, that's the normal string form of an Object. This is in part whyalert()isn't really the best tool for debugging. Try instead usingconsole.log(response)and open the Console in your browser's developer tools to view the result.