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
Post a Comment