Discussions

 View Only
  • 1.  Pipeline JSON array trailing comma in Jinja

    Posted 11-28-2022 16:25
    In case it helps someone to save a couple of hours solving this error, when you try to send a json array using jinja in pipelines.

    Error:
    Something went wrong executing a step. Try modifying your pipeline.
    Body:
    {"payments":
    [{% for r in a%}
    {"value":"{{r.vto}}"},
    {% endfor %}
    ]}

    Valid:
    {"payments":
    [{% for r in a%}
    {"value":"{{r.vto}}"}{% if not loop.last %},{% endif %}
    {% endfor %}
    ]}

    Reference: https://rogerpence.dev/omitting-the-last-comma-in-a-series-in-a-jinja-template/

    ------------------------------
    Diretoria Mirantes
    ------------------------------


  • 2.  RE: Pipeline JSON array trailing comma in Jinja

    Posted 11-28-2022 17:05
    Thanks for sharing this , The code in red is in my staple but it definitely will help others

    ------------------------------
    Prashant Maheshwari
    ------------------------------



  • 3.  RE: Pipeline JSON array trailing comma in Jinja

    Posted 11-29-2022 20:48
    I just learned from Dough Henning , an alternative way to writing the same 

    {{ ',' if not loop.last }}​


    ------------------------------
    Prashant Maheshwari
    ------------------------------