Hello,
I want to use the inserted JSON from a spefic column in hubdb.
I have two values in the JSON: colorname and colorurl
I want to get the JSON from a specifc hubdb column and use it in a module via a foreach.
Example JSON file:
[{“textvalue”:“Thorngrijs 11-05 Newtone”, “urlvalue”:“thorngrijs-11-05-newtone”},{“textvalue”:“Rood 01-76 Newtone”, “urlvalue”:“rood-01-76-newtone”}]
In the above example you see two colors (Thorngrijs 11-05 Newtone and Rood 01-76 Newtone). They have both a textvalue and urlvalue. I want to insert that JSON in a column in hubdb and load the JSON via hubl in my module.
Example Hubl code:
{# Example get JSON from hubdb column #}
{% set objects = module.row.columns[‘kleur_decibel_red_structuur_mko’] %}
{# Example test array (this works) #}
{% set objects2 = [{“textvalue”:“Thorngrijs 11-05 Newtone”, “urlvalue”:“thorngrijs-11-05-newtone”},{“textvalue”:“Rood 01-76 Newtone”, “urlvalue”:“rood-01-76-newtone”}] %}
{# display output from hubdb ( i get the JSON string, but the foreach values are empty)
{{objects}}<br><br>
{#display output from test hardcoded array (this works, but not the method what i want) #}
{{objects2}}<br><br>
{# Load textvalue and urlvalue from the hubdb column (where the JSON text is inserted) #}
{% for obj in objects %}
Title: {{obj.textvalue}} <br>Slug: {{obj.urlvalue}}<br><br>
{% endfor %}
in objects2 you can see the JSON that i want to use with the foreach, this works. But i want to use the exact same JSON text only from the hubdb column. Via hubdb it doesnt work for some reason. I get no Title or Slug as output.