0

I have a JSON array which has square bracket in key, 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 error as custTitle is not defined, i can get the other values by the same way.

kiddorails
  • 12,926
  • 2
  • 31
  • 39

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
  • 671
  • 1
  • 6
  • 19