underscore-cli icon indicating copy to clipboard operation
underscore-cli copied to clipboard

missing quotes in pretty-formatted output

Open csabahenk opened this issue 10 years ago • 2 comments

$ 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

csabahenk avatar Sep 11 '13 08:09 csabahenk

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.

JoshOldenburg avatar Jun 01 '14 00:06 JoshOldenburg

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

richlv avatar Jul 28 '14 11:07 richlv