[Solved] Get value of parent object base on value from another object [closed]


You could use filter as follows from the parsed object:

let obj = [{
  "type": 1,
  "key": "123abc",
  "data": {
    "access": "123456",
    "data": {
      "dataValue": [{
          "@attr": {
            "@key": "Fire"
          },
          "@value": "Flame"
        },
        {
          "@attr": {
            "@key": "Water"
          },
          "@value": "Liquid"
        },
        {
          "@attr": {
            "@key": "Earth"
          },
          "@value": "Stone"
        }
      ]
    }
  }
}];

console.log(obj[0].data.data.dataValue.filter(a => a["@attr"]["@key"] == "Water")[0]["@value"]);

0

solved Get value of parent object base on value from another object [closed]