I have submitted a Json string to a data extension under the field name of "products" and can see the data within Marketing Cloud:
Example data:
[{"name": "Lunch1", "quantity": "1", "bonus_products": []}, {"name": "Lunch2", "quantity": "1", "bonus_products": []}, {"name": "Lunch3", "quantity": "1", "bonus_products": [{"name": "Baked Beans"}, {"name": "Potatoes"}]}]
What I'd like to do is output the name, quantity, and also all the bonus products in my email. I'm able to output the name, and quantity, but am struggling to identify the best way to iterate through the bonus_products, which needs to be decoded
This is my code:
%%[
var @json
set @json = AttributeValue("products")
]%%
{{.dataobject JsonVar type=variable source=@json maxrows=20}}
{{.data}}
{"target":"@Json"}
{{/data}}
{{/dataobject}}
{{#each JsonVar}}
<p>{{name}}, {{quantity}}, {{bonus_products}}</p>
{{/each}}
Any advice would be greatly appreciated. Thanks,