JSON looper access key name?

I have a Looper Provider providing JSON data. One of the elements is an array with arbitrary keys. I would like to access the key names as headings.

My row is providing the following JSON:

[
	{"title": "New Job",
	 "location" : "Fairhope, AL",
	 "data" : [
	 	{"Department" : "QA"},
	 	 {"Pay" : "$100/hr"}     
     ]
	 	
	},
	{"title": "Newer Job",
	 "location" : "Point Clear, AL",
	 "data" : [
	 	{"Department" : "Jr QA"},
	 	 {"Hours" : "20"}     
     ]
	 	
	}
]

I have a Column that is a Looper Consumer,
and a Headline whose text is made up of {{dc:looper:field key="title”}} and {{dc:looper:field key="location”}}.

Following the Headline I have an Accordion block that is a Looper Provider, with the input as Dynamic Content set to {{dc:looper:field key="data”}}.

The Accordion has a single item set as a Looper Consumer.
The Content is set to {{dc:looper:item}}.
But I cannot figure out a way to set the header that will return the keys like “Department” or “Hours”, etc.

I will have an arbitrary mix of parameters under the “data” array. I really cannot restructure at this point the data with a further level of nesting where data is an array of arrays ([‘key’ => ‘hours’, ‘value’ => ’20 hours per week’]).

How can I access the key names? I can restructure the Looper & Consumers and change types.

Hi Samuel,

Thanks for reaching out.
As per the JSON structure to access the Department values you need to use the following dynamic content tag.

{{dc:looper:field key="data.0.Department"}}

Hope it helps.
Thanks

Thanks – I am able to access the content of these extra fields no problem. What I am trying to get access to is the actual key names themselves, like “Department” or “Hours,” to use as headings for my accordion item.

Right Now my accordion content shows “QA” or “$100” just fine. But the heading is blank. I don’t know how to access the key name.

Hi Samuel,

Unfortunately, you can’t access the key name using the Looper.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.