Working on parsing some JSON in the HTML of a Marketing Cloud email using GTL and AMPscript and I've figured out how to do one degree of nesting, but can't figure out how to dig down deeper than that. This is a piece of the sample JSON:
{
"section": {
"id": "ABCDEFG",
"heading": {
"name": "John Smith"}}
}
I can get it to pull "id", but not "name". What I used to successfully get to "id":
%%[
SET @title="TestTitle"
SET @JSON=Lookup("TestJSON","JSON", "Title", @title)
]%%
{{.datasource JsonVar type=variable source=@Json maxrows=20}}
{{.data}}
{"target": "@Json"}
{{/data}}
{{.datasource section type=nested source=@Json maxrows=20}}
{{.data}}
{"target": "JsonVar.section" }
{{/data}}
%%[
SET @id = TreatAsContent('{{section.id}}')
]%%
{{/datasource}}
{{/datasource}}
That works great, but when I try to reach further down to "name", I can't find a way to make that work. I've tried several AMPscript based things, and also tried adjusting to {"target": "JsonVar.section.heading" }
and TreatAsContent('{{section.heading.name}}')
but those didn't work. Is there a way to set up another layer of nesting within the above?