# Hubl fromjson filter problem reading a json string

**URL:** <https://community.hubspot.com/t/hubl-fromjson-filter-problem-reading-a-json-string/89170>\
**Category:** APIs & Integrations\
**Tags:** email, professional, contacts\
**Created:** [September 7, 2023, 1:39pm UTC](https://community.hubspot.com/t/hubl-fromjson-filter-problem-reading-a-json-string/89170 "2023-09-07T13:39:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommaso1288](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tommaso1288/32/99949_2.png) [@tommaso1288](https://community.hubspot.com/u/tommaso1288)\
**Post date:** [September 7, 2023, 1:39pm UTC](https://community.hubspot.com/t/hubl-fromjson-filter-problem-reading-a-json-string/89170/1 "2023-09-07T13:39:42Z")

</div>

Hello Everyone,  
We are sperimenting a strange behaviour: we have a custom property on Hubspost (multitext) where a JSON string is saved.  
In an email template, via Hubl we would like to retrieve that value, make it fromJson and then use the properties of the json in the template.  
Below you can see an example of code, in the first piece of code we try to read the value of the custom field “ds\_domains”, but the fromJson filter returns a NULL.  
In the second piece of code we statically reported the value of the ds\_domains property and in that case it works correctly.  
What are we doing wrong?

```auto
# Reading json string value from a custom property called ds_domains

{% set ds_json = contact.ds_domains %}
{% set obj = ds_json|fromjson %}
Json STR: {{ ds_json|pprint }} --> {"product pills": ["test123.com", "test123.it"]} "OK"
Json OBJ: {{ obj | pprint }} --> NULL (ERROR)

# Test with static value

{% set ds_json_2 = '{"product pills": ["test123.com", "test123.it"]}' %} (Static value of contact.ds_domains)
{% set obj2 = ds_json_2|fromjson %}
Json STR2: {{ ds_json_2|pprint }}
Json OBJ2: {{ obj2['product pills'] }} --> WORK

```

The preview result is:

 ![Immagine.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/d/7d4e7c9f1c00af130def5c142537b69b9c17a0f5.png)

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 8, 2023, 9:04pm UTC](https://community.hubspot.com/t/hubl-fromjson-filter-problem-reading-a-json-string/89170/2 "2023-09-08T21:04:22Z")

</div>

Hey, @tommaso1288 👋 Did you get this worked out?

If not, have you tried using the HubL filters [trim](https://developers.hubspot.com/docs/cms/hubl/filters#trim) and [striptags](https://developers.hubspot.com/docs/cms/hubl/filters#striptags) to check the formatting for the JSON string you’re storing in the ds\_domains property?

Also, have you double-checked your escaping of slashes? Making sure to use double backslashes (`\\`) in places where you would normally use one (`\`)

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![tommaso1288](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tommaso1288/32/99949_2.png) [@tommaso1288](https://community.hubspot.com/u/tommaso1288)\
**Post date:** [September 12, 2023, 7:57am UTC](https://community.hubspot.com/t/hubl-fromjson-filter-problem-reading-a-json-string/89170/3 "2023-09-12T07:57:51Z")

</div>

Hi Jaycee,

thank you for your kind reply, yes I tried both trim and the various filters for json or slash escaping.  
Finally, reading the hubl documentation I found this:  
“_you can apply HubL filters to personalization tokens, such as contact and company tokens, on HubSpot CMS and blog pages, but not in emails_.”  
In fact, I tried using the split filter instead of fromjson on a test string (a\_b\_c) read from a custom property and noticed that the split is done not on the value of the custom property but on its name.  
**Example** :

```lia-code-sample
{% set ds_domains = contact.ds_domains %}
{% set names = ds_domains | split("_") %}
{{ names }}

```

**names** → **[contact.ds, domains]** and not [a, b, c]

Probably the fromJson filter does the same thing, it applies it to the name of the custom property and not to its value and therefore (not being a valid json) it returns a null.
