javascript - Lopping through nested JSON with dynamic names -


this question has answer here:

so have json named test_json , need authorss out of it.

{         name:'test',         content:         {             "dynamicvar1":             {                 "author":'bla'             },             "also-dynamicbutother-123-name":             {                 "author":'bla2'             }         }     } 

the problem since "dynamicvar1" , "also-dynamicbutother-123-name" have changing names - can't access author.

i've tried this, doesn't work , don't know go here.

for (let x in test_jason.content){         console.log(test_jason.content.x.author) //undefined     } 

var obj = {    name:'test',    content:    {      "dynamicvar1":      {          "author":'bla'      },      "also-dynamicbutother-123-name":      {          "author":'bla2'      }    }  }    (let x in obj.content){    console.log(obj.content[x].author)  }


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -