Build array of strings and wrap them in quotations marks

I am trying to generate this output:

["index", "last", "first"]

from an inital (potentially empty) string:
{%- assign rels = link.rel -%}

and conditional additions to that string:
{%- if first -%}{%- assign rels = rels | append: ",first" -%}{%- endif -%}
{%- if last -%}{%- assign rels = rels | append: ",last" -%}{%- endif -%}

I am then splitting the rels and try to remove empty items (not working)
`{%- assign rels = rels | split: “,” | compact -%}

And then I render it:

    {% for rel in rels %}
      {% unless forloop.last %},{% endunless %}
    {% endfor %}

I hope there is an easier, more compact way to do that?

Something like this would be nice:

[ {{ rels | split: "," | prepend: '"' | append: '"' }} ]

Can be easily achieved by using the inspect filter if you have control over the input string.
For example, test with the following sample page content:

rels: index,last,first

{{ page.rels | split: "," | inspect }}

Thanks! Sounded nice, but inspect outputs quoted entities. But I need to use it in json, so I need the real quotation marks and not "

You can also try using the jsonify filter.
That said, I get <p>["index", "last", "first"]</p> when testing with either Jekyll 3.8.6 or Jekyll 4.0.0.

Jekyll’s Markdown converter generates output meant for HTML pages. It doesn’t know how to generate JSON.

Your use case is not exactly clear now.