Open ingenthr opened 3 years ago
I think that looping does work but it's going to be tricky to generate valid JSON. In your loop your objects need to be separated by a comma:
{% for i in range(end=5) %}
{ "qty": "{{ numberWithFormat(format='^#')}}",
"item": "{{ words(num=3) }}" },
{% endfor %}
The problem is then that it'll still generate invalid JSON because it'll generate a trailing comma.
The following works but is... icky:
{
"id": "{{ uuid() }}",
"content": {
"order_by": "{{ userName() }}",
"address": "{{ numberWithFormat(format='^####') ~ ' ' ~
streetName() ~ '\n' ~
cityName() ~ ', ' ~
stateAbbr() ~ ' ' ~
postCode() }}",
"order_items": [
{% for i in range(end=5) %}
{ "qty": "{{ numberWithFormat(format='^#')}}",
"item": "{{ words(num=3) }}" }
{% if i < 4 %}
,
{% endif %}
{% endfor %}
],
"type": "order"
}
}
based on tera, I tried this…
But it does not work. There does not seem to be looping support?