underscore-cli
underscore-cli copied to clipboard
missing quotes in pretty-formatted output
$ echo '{"a":null}' | underscore print --outfmt pretty
{ a: null }
(nb. non-prettified output is fine:
$ echo '{"a":null}' | underscore print
{ "a": null }
)
$ underscore --version
0.2.17
When printing array-and-object graphs that can be generated by JSON.parse, the output is valid JavaScript syntax (but not strict JSON). When handling complex objects not expressable in declarative JavaScript (eg arrays that also have object properties), the output is informative, but not parseable as JavaScript.
This is by design. The default format (json
), dense
, and stringify
are valid JSON. The pretty
format is mainly intended to be easily readable, though is valid JS when it's just arrays and objects.
it would be great to have an option for pretty printing not to modify input, except the whitespace (spacing, newlines etc) - that would allow to use it as a reformatting solution