Live data from Hacker News

The Pretty JSON Revolution

ohler.com

1–10 of 159 posts

Re: The Pretty JSON Revolution

#3
If you're on a mac or Linux system, you likely have a JSON formatter already installed

`python3 -m json.tool somefile.json` or `cat foo.json | python3 -m json.tool` will print it in "one line per node" format. 3.9 introduces a --sort-keys switch for sorted objects also.

Re: The Pretty JSON Revolution

#5
post #3

If you're on a mac or Linux system, you likely have a JSON formatter already installed `python3 -m json.tool somefile.json` or `cat foo.json | python3 -m json.tool` will print it in "one line per node" format. 3.9 introduces a --sort-keys switch for sorted objects also.

I would be a little nervous sorting the keys. I thought it was not too uncommon for parsers to treat them as an alist where order matters. I guess so long as it is a stable sort, no big deal?

Re: The Pretty JSON Revolution

#6
post #2

This beautiful post is missing a last section called "Gron: do away with json altogether and print something actually readable". That would be a good punchline!

Interesting idea. Solves the issue of trying to find data in JSON fairly well. I'm a bit biased but I like using the oj with a JSONPath extraction (-x option) to do something similar but with the power of JSONPath.

Re: The Pretty JSON Revolution

#8
post #3

If you're on a mac or Linux system, you likely have a JSON formatter already installed `python3 -m json.tool somefile.json` or `cat foo.json | python3 -m json.tool` will print it in "one line per node" format. 3.9 introduces a --sort-keys switch for sorted objects also.

I did not know about sort keys. I'm adding that to my alias. Thank you.

Re: The Pretty JSON Revolution

#10
I would prefer one that aligned the like named keys, if it fits in screen. Makes it dead easy to scan the values.

That said, it is just another pun on the text as art thing. In that it doesn't really scale, and you are going to upset someone by not having a codified tool for automatically doing this. (I don't recall seeing align-regex in any popular tool.)

Post reply on HN