jQuery.map() and nested JSON array
Hi all,
I try to use map() function to parse JSON data and build bullet list in Html. The JSON data have is:
- {"Successful":false,"ModelState":[{"Key":"MyDataField","Value":{"Value":null,"Errors":[{"Exception":null,"ErrorMessage":"My Error Message Here!!."}]}}]}
It contains 2 level of nested array here, I try to extract all ErrorMessage from the data and build <ul><li><li></ul>.
- var bulletList = $.map(data.ModelState, function (item, a) {
var temp = JSON.stringify(item.Value.Errors);
alert(temp);
return "<li>" + item.Value.Errors.ErrorMessage;
});
- $("#ErrorMessageList").html(bulletList.join(""));
Above is my JS code, but it seems that I am unable to get ErrorMessage from 2nd array, do I have to use 2 jQuery.map() in this case?
Thanks
Hardy