Hi all !
I have a contact property as a JSON string that is not recognized as JSON in HubL template named dispos :
valid json but too long
{"days":[{"col":0,"rows":[{"row":0,"cellPresent":true,"span":0}, .... {"row":22,"cellPresent":true,"span":0},{"row":23,"cellPresent":true,"span":0}]}]}
I cannot find a way for this json string to be converted to a JSON object in my module :
{% set calendar = contact.dispos |fromjson %}
{% set columnHeaders = ['Heures', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'] %}
{% macro renderRow(rowIndex) %}
<tr>
<td>{{"%02d"|format(rowIndex)}}:00 - {{rowIndex==23 ? "00" : "%02d"|format(rowIndex + 1)}}:00</td>
{% for elem in calendar.days %}
{{renderCell(rowIndex, elem)}}
{% endfor %}
</tr>
{% endmacro %}
{% macro renderCell(rowIndex, elem) %}
{%set cellInfo = elem.rows[rowIndex] %}
{% if cellInfo.cellPresent %}
<td
{% if cellInfo.span > 0 %}
rowspan="{{ cellInfo.span }}" style="background-color:#1F8E92"
{% endif %}
></td>
{% endif %}
{% endmacro %}
{% set test = contact.dispos | json %}
<span>{{ test.days[0].col }}</span>
<table border="1">
<tr>
{% for header in columnHeaders %}
<th>{{ header }}</th>
{% endfor %}
</tr>
{% for x in range(0,24) %}
{{renderRow(x)}}
{% endfor %}
</table>
Any help is much appreciated !
Philippe