Parsing json object in javascript with empty property name
If I have the json object below ... how can I access the "Passwords must have ..." line.
The property name name "" inside ModelState is confusing to me.
Thank!
{
"Message": "The request is invalid.",
"ModelState": {
"": [
"Passwords must have at least one non letter or digit character. Passwords must have at least one uppercase ('A'-'Z')."
]
}
}
+3
source to share
5 answers
You can achieve this in the following way:
var somedata = {
"Message": "The request is invalid.",
"ModelState": {
"": [
"Passwords must have at least one non letter or digit character. Passwords must have at least one uppercase ('A'-'Z')."
]
}
};
console.log(somedata["ModelState"][""]);
0
source to share