1

I have json file called list.json:

{
  "nvg":{
  "Title":"title",
  "Description":"description",
  "Image":"",
  "URL":{
    "DEV":"https://dev.com",
    "TEST":"https://test.com",
    "PROD":"https://prod.com"
    }
   }

I have an array

var apps = ["nvg"];

I want to access the json data and extract the object based on the variable's value. Does anyone know how to pass the [i] into the json call?

  var getConfig = $.getJSON( data, function( json ) {
    var apps = ["nvg"];
    
    apps.forEach(function(i){
      alert(i);
      alert(json.i.URL.DEV);
    });
  
  });

Like the code above, but to actually the "i" to pass the value defined in the array?

BobbyGIS
  • 31
  • 2

1 Answers1

0

You should be able to access the data using your Javascript object like an object or array. This means you can do the following:

alert(json[i].URL.DEV);
Thomas
  • 442
  • 4
  • 11