Help with scripts concatenating strings

I’m writing a script but I have problems transforming strings:

this:

data: 
   \"{\"points\":[[{{ path[repeat.index-1][0] }},2323,1,1,1]]}\"

is returning this:
\"{\"points\":[[228,2323,1,1,1]]}\"

if I use

data: 
  "{\"points\":[[{{ path[repeat.index-1][0] }},2323,1,1,1]]}"

is returning

          points:
            - - 228
              - 2323
              - 1
              - 1
              - 1

I need to have something like this:
"{\"points\":[[228,2323,1,1,1]]}"

could you please help me?

https://www.home-assistant.io/docs/configuration/templating/#tofrom-json

1 Like

I tried this:

value: >-
                  {% set json = "{\"points\":[[" ~ path[repeat.index-1][0] ~
                  ",2323,1,1,1]]}" %} {{ json | to_json}}

but the result is:

value: '"{\"points\":[[228,2323,1,1,1]]}"'

how to get rid of ’ ?