I have a json file called values.json
with different atributes:
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
Using Jinja2, I am trying to import it and get just value1
, but i don't find the way of doing it.
I manage to import all the json and print it in a file called test.j2
:
{%- import "./values.json" as values -%}
{{ values}}
but I don't know how to get only the value of key1
. I am trying to convert first the file to json and then get the value:
{%- import "./values.json" as values -%}
{% set values_json = values | string | tojson %}
{{ values_json.key1 }}
But I get an empty response. Do you know how I should do it?
The command I use to test it is jinja2 test.j2