0

I have the following object structure and for each record I need to display the attribute name and its value. for the following example, I need to display "Name " = xxx. The attribute name can be different for each json response. These are field names of a table so I cann't use hard coded names. How do I read the attribute value? I tried var propname = DataInObj.DataSet[0].Record[0].properties[1] but it didn't work. Pls help

object
  REcord
    +attributes
    -0                
     Name              xxx
     Amount            100
    +attributes
    -1
     Name              yyy 
     Amount            200
Refeekh M
  • 31
  • 3

1 Answers1

1

See this other post: Iterate over an object in Google Apps script

Code goes like this:

var dict = { "foo": "a", "bar": "b" };

function showProperties(){ 
    var keys = []; 
    for(var k in dict) keys.push(k+':'+dict[k]); 
    Logger.log("total " + keys.length + "\n" + keys.join('\n')); 
 }
Community
  • 1
  • 1
Serge insas
  • 45,904
  • 7
  • 105
  • 131