Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JSON is an OK serialization format, and a terrible format for outputting human readable data. Let's take, for example, the output of 'ls -al' and imagine it were presented via JSON:

The keys 'mode', 'number of links', 'owner', 'group', 'size', 'last modified' would be repeated over and over again, stacked vertically.

Mode would remain an arbitrarily formatted string, or (worse) be broken into its own object for every attribute represented by the string.

A reasonably populated directory would fill multiple screens with cruft.

The formatting of the timestamp in the last modified field would still be an arbitrary string.

Comparing two files would require piping through another utility to extract just the appropriate fields and display them unadorned.

Sure, it might be moderately easier to consume in another program since you can simply iterate over a list and reference specific keys, but it's not really that hard to iterate over a list of lines and extract a specific field by number.

    ls -al | awk '{print $5,$9}'
vs.

    ls -al | jq '.[] | [.size,.name|tostring] | join(" ")'


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: