Hi,
I’m trying to build custom json file like this :
{
“client”: {
“subscriptions”: {{ sensu_client_subscriptions | to_nice_json }}
{% if sensu_autoderegister %}
,“deregister”: true,
“deregistration”: {
“handler”: “deregister_client”
}
{%endif%}
{% if sensu_custom_value %}
,{{ sensu_custom_value| to_nice_json }}
{%endif%}
}
}
with variable :
sensu_custom_value:
disk:
warning: “85”
critical: “90”
postfix:
warning: “10”
critical: “20”
My issue is with {{ sensu_custom_value| to_nice_json }}
it’s produce unwanted (for me) extra bracket :
,{
“disk”: {
“critical”: “90”,
“warning”: “85”
},
“postfix”: {
“critical”: “20”,
“warning”: “10”
}
}
i whould like to have, instead :
Hi,
I'm trying to build custom json file like this :
{
"client": {
"subscriptions": {{ sensu_client_subscriptions | to_nice_json }}
{% if sensu_autoderegister %}
,"deregister": true,
"deregistration": {
"handler": "deregister_client"
}
{%endif%}
{% if sensu_custom_value %}
,{{ sensu_custom_value| to_nice_json }}
{%endif%}
}
}
with variable :
sensu_custom_value:
disk:
warning: "85"
critical: "90"
postfix:
warning: "10"
critical: "20"
My issue is with {{ sensu_custom_value| to_nice_json }}
it's produce unwanted (for me) extra bracket :
That because the correct representation of sensu_custion_value in json need to have those brackets.
,{
"disk": {
"critical": "90",
"warning": "85"
},
"postfix": {
"critical": "20",
"warning": "10"
}
}
i whould like to have, instead :
,
"disk": {
"critical": "90",
"warning": "85"
},
"postfix": {
"critical": "20",
"warning": "10"
}
any idea ?
You could do something like this, iterate over the keys and print an output.
{% for key in sensu_custom_value %},\n"{{ key }}": {{ sensu_custom_value[key] | to_nice_json }}{%endfor%}