score:1

Accepted answer

As @Nick's comment, the type of context is an array. So you should access it by index like below

var data = [
      {
          "id": "00000", 
          "type": "company", 
          "name": "Ideal-Phones", 
          "icon": "\uf1ad",
          "level" :"0",
          "display" : "block",
          "context": [
              {"context-id": "10000", "name": "phone"}
          ]
      }
   ];
var firstItem = data[0].context;
console.log("Is array: " + Array.isArray(firstItem));

var firstContext_of_firstItem = firstItem[0];
console.log("Value: " + firstContext_of_firstItem.name);

More requirement: Loop and compare the name of property

var data = [
      {
          "id": "00000", 
          "type": "company", 
          "name": "Ideal-Phones", 
          "icon": "\uf1ad",
          "level" :"0",
          "display" : "block",
          "context": [
              {"context-id": "10000", "name": "phone"},
              {"context-id": "10001", "name": "Ideal-Phones"},
          ]
      }
   ];
   
for(let item of data){
  var name_of_item = item.name;
  for(let childContext of item.context){
    var name_of_child_context = childContext.name;
    if(name_of_item === name_of_child_context){
      // do something here
      console.log(childContext);
    }
  }
}

score:0

This code will write to console the desired output "phone"

var txt = '[{\"id\":\"00000\",\"type\":\"company\",\"name\":\"Ideal-Phones\",\"icon\":\"\uf1ad\",\"level\":\"0\",\"display\":\"block\",\"context\":[{\"context-id\":\"10000\",\"name\":\"phone\"}]},{\"id\":\"00100\",\"type\":\"software\",\"name\":\"Jira\",\"icon\":\"\uf7b1\",\"parent\":\"00000\",\"level\":\"1\",\"display\":\"none\",\"context\":[{\"contxt-id\":\"10001\",\"name\":\"Jira\"}]}]'
var obj = JSON.parse(txt);
alert(obj[0].context[0].name);

Related Query

More Query from same tag