Webhook request body JSON error

I am trying to put together a simple webhook that will send invoice details to an integration system I am writing. If I use form-encoded for the request body, I can get it to send the list of items, but I want to be able to customize which fields it sends, so I think I need to use JSON. However, when I try to do that, it throws an error saying it’s invalid JSON. I am sure it’s just that I am unfamiliar with the templating engine, but I can’t figure out how to make it work. Current JSON:

{
    "quickbooksId": "{{doc.quickbooks_id}}",
    "name": "{{doc.name}}",
    "items": [
        {%for item in doc.items%}
            {
                "item_code": "{{item.item_code}}"
            }
        {%endfor%}
    ]
}

Each object in array needs to be separated by comma except for the last one.

I understand that for valid JSON it needs a comma, but unless I remove the

{%for item in doc.items%}

and the

{%endfor%}

It tells me I have invalid JSON syntax, whether I have a comma there or not.