I want to add a new key-value pair in JSON object with nunjucks template, but unable to add it(don't want to add any custom filter).
suppose I have an object
var obj = {"id": "1", "name": "test", "child": {"id": "2", "status": "true"},
"template": "{{obj.child}}"}
Now I want to add a new key like
{"template": "{% set json = obj.child %}{% set json.name = 'testing' %}"}
So the final output as I want
{
"id": "1",
"name": "test",
"child": {
"id": "2",
"status": "true"
},
"template": {
"id": "2",
"status": "true",
"name": "testing"
}
}
Please let me how can I do?