{# Macro für schöne JSON-Darstellung - kompakt und lesbar #} {% macro renderJsonValue(key, value, level) %} {% if value is iterable and value is not same as('') and value is not same as([]) %} {# Array oder Objekt #} {% set valueKeys = value|keys %} {% set isNumericArray = false %} {% if valueKeys|length > 0 %} {% set firstKey = valueKeys|first %} {% if firstKey is not iterable and firstKey is not same as('') and firstKey matches '/^\\d+$/' %} {% set isNumericArray = true %} {% endif %} {% endif %} {% if isNumericArray %} {# Numerisches Array - prüfe ob Elemente Objekte sind #} {% set hasObjectItems = false %} {% if value|length > 0 %} {% set firstItem = value|first %} {% if firstItem is iterable and firstItem is not same as('') and firstItem is not same as([]) and (firstItem|keys|length > 0) %} {% set hasObjectItems = true %} {% endif %} {% endif %} {% if hasObjectItems %} {# Array von Objekten - zeige als verschachtelte Liste #}