j2cli icon indicating copy to clipboard operation
j2cli copied to clipboard

Arrays in json

Open nickstatka777 opened this issue 4 years ago • 1 comments

Hello, I have a problem. When I try to pass an array from a template.json to the dest JSON file the result looks incorrect: example: template file: { "inpath": ["/2_dir","/3_dir"] }

in the destination file: { "paths": ['/2_dir', '/3_dir'] } I'm about single quote, however, it should be double quotes. So, what do I wrong?

nickstatka777 avatar May 23 '20 11:05 nickstatka777

@nickstatka777 This can be accomplished using the tojson filter like so:

{{ my_array | tojson }} 

robmoore avatar Aug 26 '20 15:08 robmoore