File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 11# Using Built-in Helpers
22<!--
3- Copyright 2024 Google LLC
3+ Copyright 2025 Google LLC
44
55 Licensed under the Apache License, Version 2.0 (the "License");
66 you may not use this file except in compliance with the License.
@@ -220,8 +220,33 @@ The file path is relative to the main template file directory.
220220}
221221```
222222
223-
224223
224+ ### ** json_to_yaml**
225+ ``` go
226+ func json_to_yaml (json string ) string
227+ ```
228+
229+ Converts the input JSON string to YAML.
230+
231+ e.g.
232+ ```gotemplate
233+ {{ $YAML_TEXT := ` {"hello":"world"}` | json_to_yaml }}
234+ {{ print $YAML_TEXT }}
235+ ```
236+
237+
238+ ### ** yaml_to_json**
239+ ``` go
240+ func yaml_to_json (yaml string ) string
241+ ```
242+
243+ Converts the input YAML string to JSON.
244+
245+ e.g.
246+ ```gotemplate
247+ {{ $YAML_TEXT := ` {"hello":"world"}` | json_to_yaml }}
248+ {{ print (yaml_to_json $YAML_TEXT) }}
249+ ```
225250
226251## Libraries
227252### ** Sprig**
Original file line number Diff line number Diff line change 124124 }
125125 }
126126
127+ json_to_yaml(string) string
128+ Converts the input JSON string to YAML. e.g.
129+
130+ {{ $YAML_TEXT := `{"hello":"world"}` | json_to_yaml }}
131+ {{ print $YAML_TEXT }}
132+
133+ yaml_to_json(string) string
134+ Converts the input YAML string to JSON
135+
136+ {{ $YAML_TEXT := `{"hello":"world"}` | json_to_yaml }}
137+ {{ print (yaml_to_json $YAML_TEXT) }}
138+
139+
127140 Sprig
128141 Template functions from Sprig library
129142 e.g. {{ "Hello World" | upper }}
You can’t perform that action at this time.
0 commit comments