0

I have a JSON array that has a square bracket in the key, for example:

{
  "msg":"OK",
  "data":[
    {
      "nls!type":"NCR",
      "current":"Assign",
      "physicalid":"0FFE0001000009FC5BD6805C00001352",
      "attribute[custTitle]":"Title",
      "name":"181002",
      "description":""
    }
  ]
}

how do I get the value of "attribute[custTitle]" in javascript

When I try to get arrData[i].attribute[custTitle] it returns an error as custTitle is not defined, I can get the other values in the same way.

Ahmad Adibzad
  • 501
  • 2
  • 6
  • 14

1 Answers1

2

try this

const response = {
  "msg":"OK",
  "data":[
    {
      "nls!type":"NCR",
      "current":"Assign",
      "physicalid":"0FFE0001000009FC5BD6805C00001352",
      "attribute[custTitle]":"Title",
      "name":"181002",
      "description":""
    }
  ]
};

console.log(response.data[0]['attribute[custTitle]']);
Saad Mehmood
  • 691
  • 1
  • 7
  • 19