This Commented CUE
demonstrates how to use the built-in function
encoding/json.Compact
to transform a JSON file into a single line of JSON with all insignificant
whitespace removed.
file.cue
package example
import "encoding/json"
compact: json.Compact(json.Marshal(input))
// The contents of data.json is placed here by
// the -l parameter.
input: _
data.json
{
"a": 1,
"b": {
"c": "two",
"d": 3.0
},
"e": false,
"f": [
4,
5.0,
"A\nMulti\nLine\nString"
]
}
TERMINAL
$ cue export file.cue -l input: data.json -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