Skip to content

Conversation

@koenpunt
Copy link

@koenpunt koenpunt commented Jul 16, 2019

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 }}

for easy representation of json values I've added a JSON function that feeds the value to the json marshaller.
@koenpunt
Copy link
Author

Ping ✨

@sagikazarmark
Copy link

Would toJson implemented in #140 work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants