提醒json响应

I have the following json response I need to alert errors object through javascript.

{"sEcho":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":{null},"errors":{"msisdn":"num\u00e9ro de t\u00e9l\u00e9phone non valide"}}

I m newbie with json and I couldn't find a way to alert my error rendered by my controller.

Many Thx

Try this:

// your json data
var s = '{"sEcho":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":"{null}","errors":{"msisdn":"phone non valide"}}';

// change in json object
var obj = JSON.parse(s);

// get errors value
console.log(obj.errors);

Make sure that you have valid json data.

Try with below code

var j = '{"sEcho":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":null,"errors":{"msisdn":"num\u00e9ro de t\u00e9l\u00e9phone non valide"}}';
var a = JSON.parse(j);
alert(a.errors.msisdn);

It will display message of msisdn property of errors, as msisdn is child property of errors.