I am getting this back from the server:
{"Message":"The request is invalid.","ModelState":{"":["Name greg@gmail.com is already taken.","Email 'greg@gmail.com' is already taken."]}}
How do I reference the first item of the array in JS? The debugger tells me that ModelState is an object, but there seems to be no name for the array.
答案 0 :(得分:2)
var jsonString = {"Message":"The request is invalid.","ModelState":{"":["Name greg@gmail.com is already taken.","Email 'greg@gmail.com' is already taken."]}};
console.log(jsonString.ModelState[''][0]);
答案 1 :(得分:1)
if test = {"Message":"The request is invalid.","ModelState":{"":["Name greg@gmail.com is already taken.","Email 'greg@gmail.com' is already taken."]}}
then your array is at test['ModelState'][""]