dockerize
dockerize copied to clipboard
Add json function to output value as JSON
For easy representation of json values I've added a JSON function that feeds the value to the json marshaller.
The signature has a variable number of arguments, where the first is the data to marshal, the second (optional) argument is the prefix (to match existing indentation), and the third (optional) argument is the indentation to use.
Contrived example:
{{ with $jsonDoc := `{
"services": [
{
"name": "service1",
"port": 8000
}, {
"name": "service2",
"port": 9000
}
]
}` }}
{{- $services := jsonQuery $jsonDoc "services" -}}
{
"services": {{ json $services " " " " }}
}
{{ end }}
Ping ✨
Would toJson
implemented in #140 work for you?