# Issue with 'fromjson' Filter on Nested Objects in Programmable Emails

**URL:** <https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944>\
**Category:** CMS Development\
**Tags:** marketing-email\
**Created:** [March 7, 2024, 10:01am UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944 "2024-03-07T10:01:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuliaVallina](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JuliaVallina](https://community.hubspot.com/u/JuliaVallina)\
**Post date:** [March 7, 2024, 10:01am UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/1 "2024-03-07T10:01:05Z")

</div>

Hello,

I’m encountering an issue with the ‘fromjson’ filter when attempting to work with nested objects in programmable emails.

Specifically, I’m using the ‘fromjson’ filter to parse a string property from a contact. The goal is to convert it into a JSON object and then iterate over an array within this object. However, I’ve run into a specific challenge when it comes to nested objects in the resulting JSON.

Below is an example code snippet that illustrates the issue:

`<p>With user data (not working)</p>{% set data = contact.json_test|fromjson %}{{ data }}{% for item in data %}<p>name: {{ loop.index }} {{ item.name }}</p>{% endfor %}<p>With static data (works)</p>{% set test = '[{"name":"test","object":{"name":"another test"}}]'|fromjson %}{{ test }}{% for item in test %}<p>name: {{ loop.index }} {{ item.name }}</p>{% endfor %}`

The value of the contact’s property I’m testing

 ![image.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/2/62bddd291771ed3c17a3f97d0a6c4606d0abfea7.png)  
property in contact

The result

 ![image.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/f/4f39cced1700858e8bb98ea2dc21ebe0c45c2b45.png)  
result

I have tried addressing this problem by:

- using the ‘escapejson’ filter

- escaping the nested curly braces with ‘{{’ and ‘\{’

But so far, I haven’t had success.

Could you please provide assistance in resolving this issue?

I appreciate any guidance or suggestions you can offer.

---

<div class="post-metadata">

**Author:** ![DianaGomez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dianagomez/32/48035_2.png) [@DianaGomez](https://community.hubspot.com/u/DianaGomez)\
**Post date:** [March 8, 2024, 8:06am UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/2 "2024-03-08T08:06:50Z")

</div>

Hi @JuliaVallina,

Thanks for reaching out to the Community!

Let’s seek guidance from a few experts:

Hello @albertsg, @Jnix284, @GRajput - Could you please share any insights or suggestions for @JuliaVallina?

The time and expertise you contribute are truly valued!

Thanks,

Diana

---

<div class="post-metadata">

**Author:** ![erindigsmusic](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/erindigsmusic/32/1195_2.png) [@erindigsmusic](https://community.hubspot.com/u/erindigsmusic)\
**Post date:** [March 11, 2024, 5:32pm UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/3 "2024-03-11T17:32:07Z")

</div>

Programmable emails have a couple of known bugs, and this is one of them!

HTML that is included in a contact property will be escaped and rendered as a string instead of HTML. This is due to escaping being enabled by default within the new renderer. To render HTML in contact properties use the [safe filter.](https://developers.hubspot.com/docs/cms/hubl/filters#safe)

{{ contact.property\_with\_html | safe }}  
Give that a try and let me know if that doesn’t do the trick!

---

<div class="post-metadata">

**Author:** ![JuliaVallina](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JuliaVallina](https://community.hubspot.com/u/JuliaVallina)\
**Post date:** [March 12, 2024, 9:01am UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/4 "2024-03-12T09:01:47Z")

</div>

Thanks for your answer.

I’m not sure what I am suppose to do with the `safe` filter.

There is no HTML in my object, just nested objects.

I tried to chain it here and nothing happens:

`{% set data = contact.json_test|fromjson|safe %} // not working{% set data = contact.json_test|safe|fromjson %} // not working either`

---

<div class="post-metadata">

**Author:** ![benbrophy](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@benbrophy](https://community.hubspot.com/u/benbrophy)\
**Post date:** [September 17, 2024, 10:57pm UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/5 "2024-09-17T22:57:59Z")

</div>

Hi Julia - having the same issue. Did you ever figure this one out?

Reading through the Slack, it seems like some people have been able to get this to work, but I haven’t been able to.

Example of someone getting it working: [Slack](https://hubspotdev.slack.com/archives/C2YH119N2/p1694093214156539)

---

<div class="post-metadata">

**Author:** ![JuliaVallina](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JuliaVallina](https://community.hubspot.com/u/JuliaVallina)\
**Post date:** [September 18, 2024, 7:36am UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/6 "2024-09-18T07:36:39Z")

</div>

Hi Ben,

No, I couldn’t get it to work. Luckily, I had control over the JSON object in I wanted to manipulate, and I could transform it into a single-level object.

So, instead of creating a JSON like this in my contact property:

`{% set test = '[{"name":"test","object":{"name":"another test"}}]'|fromjson %}`

I went for:

`{% set test = '[{"name":"test","object_name":"another test", "object_other": [1,2,3]}]'|fromjson %}`

---

<div class="post-metadata">

**Author:** ![benbrophy](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@benbrophy](https://community.hubspot.com/u/benbrophy)\
**Post date:** [September 18, 2024, 2:20pm UTC](https://community.hubspot.com/t/issue-with-fromjson-filter-on-nested-objects-in-programmable-emails/101944/7 "2024-09-18T14:20:03Z")

</div>

Oh, ok, nice. Glad you were able to get it to work. I eventually got it working, as well. I was trying to use a custom-coded DND template, but had to use a regular DND template instead.
