I need to provide a JSON formatted information from a CMS into a web page.
There may be deep nested structures in the page input like:
{
  "input": [
    {
      "header": "sample header text",
      "description": "sample description text",
      "content": {
        "json": {
          "children": [
            {
              "type": "paragraph",
              "children": [
                {
                  "text": "sample child text "
                },
                {
                  "href": "https://myorg/tilasto/kony",
                  "type": "link",
                  "title": "Linkki ",
                  "children": [
                    {
                      "text": "sample child text"
                    }
                  ]
                },
                {
                  "text": "sample child text"
                }
              ]
            },
            {
              "type": "table",
              "children": [
                {
                  "type": "table_body",
                  "children": [
                    {
                      "type": "table_row",
                      "children": [
                        {
                          "type": "table_cell",
                          "children": [
                            {
                              "type": "paragraph",
                              "children": [
                                {
                                  "text": "sample text"
                                }
                              ]
                            },
                            {
                              "type": "table",
                              "children": [
                                {
                                  "text": "sample text"
                                }
                              ]
                            },
                            {
                              "type": "paragraph",
                              "children": [
                                {
                                  "text": "sample text"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "type": "table_cell",
                          "children": [
                            {
                              "type": "paragraph",
                              "children": [
                                {
                                  "text": "sample text"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "references": [
        ]
      }
    }
  ]
}
How can I recursively do the same thing as in the below HTML?
{% for tiedote in input %}
    <br>
<h2> {{tiedote.header}}</h2>
<p> {{tiedote.description}} </p>
{% for children_list in tiedote.content.json.children %}
    {% for child in children_list.children %}
        <p> {{child.text}} </p>
        <a href="{{child.href}}">
        {% for chil in child.children %}
            <p> {{chil.text}} </p>
            <a href="{{chil.href}}">
            {% for chi in chil.children %}
                <p> {{chi.text}} </p>
                <a href="{{chi.href}}">
                {% for ch in chi.children %}
                    <p> {{ch.text}} </p>
                    <a href="{{ch.href}}">
                {% endfor %}
            {% endfor %}
        {% endfor %}
    {% endfor %}
{% endfor %}
{% endfor %}
Also href may be present in some level of the input, how can I check if it is present or not?
Updated: In order to use macro (as in answer) in jinja template do I need to install django-macros or would there be any other means for that?
 
    