jinja json template adds an extra comma breaking json structure

Hi,

  "interval": 5, 
  "standalone": true
\},

}

I'm not sure if I understand your issue correctly... but with jinja2 you can check if you are at the end of a loop:

{% if loop.last %}some text at the end.{% else %}some text in between,{% endif %}

So your last loop should insert "," only if not at the end...?

HTH, Sascha.

Stellvertretender Vorsitzender des Aufsichtsrates: Detlef Hillebrand
Geschäftsführung: Michael Krüger
Sitz der Gesellschaft: Halle/Saale
Registergericht: Amtsgericht Stendal | Handelsregister-Nr. HRB 208414
UST-ID-Nr. DE 158253683

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Empfänger sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail oder des Inhalts dieser Mail sind nicht gestattet. Diese Kommunikation per E-Mail ist nicht gegen den Zugriff durch Dritte geschützt. Die GISA GmbH haftet ausdrücklich nicht für den Inhalt und die Vollständigkeit von E-Mails und den gegebenenfalls daraus entstehenden Schaden. Sollte trotz der bestehenden Viren-Schutzprogramme durch diese E-Mail ein Virus in Ihr System gelangen, so haftet die GISA GmbH - soweit gesetzlich zulässig - nicht für die hieraus entstehenden Schäden.

Thanks Lucas!

I was able to accomplish my goal with

`
{% if not loop.last %}

I’d possibly recommend not building it this way, but instead building your datastructure out programatically using Jinja2 statements.
This way you’re basically iterating in Python, and setting things in Python.

fake example follows

{% for x in y %}

{% datastructure = ‘some expression’ %}
{% endfor %}

At the end of the template, just dump your datastructure with:

{{ datastructure | to_nice_json }}

Templating a JSON file seems like pain to me, and that would be a lot easier.