This Commented CUE
demonstrates how to use the built-in function
encoding/json.Compact
to transform CUE data into a single line of JSON with all insignificant
whitespace removed.
file.cue
package example
import "encoding/json"
compact: json.Compact(json.Marshal(data))
data: {
a: 1
b: {
c: "two"
d: 3.0
}
e: false
f: [
4,
5.0,
"""
A
Multi
Line
String
""",
]
}
TERMINAL
$ cue export file.cue -e compact --out text
{"a":1,"b":{"c":"two","d":3.0},"e":false,"f":[4,5.0,"A\nMulti\nLine\nString"]}
Related content
- The
encoding/json
built-in package