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
0

1 Answer 1

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')); 
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.