Convert yaml to Json jinja2

I was able to convert a list of yaml to Json format.

The below is my yaml.

Listofstrings:
- s1
- S2
Etc

{% for in in listofstrings %}
{ Stringslist : [
{ String : " { i } " },
]
{% end %}

So how do I remove the last comma in my json file to ensure proper Json format.

The Q's may sound naive but any help is greatly appreciated.

I wouldn't recommend handcrafting json. Have a look at the to_json and
to_nice_json filters:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#filters-for-formatting-data

Dick