News for hackers. Stuff that matters.
Re:Httpie: A CLI http client by cellover on Tuesday October 20, 2015 @10:20AM (#10419286)
I did not know about jq, thanks!

Without jq, you can still pipe to python json.tool module:

$ curl http://domain.com | python -m json.tool

Re:Httpie: A CLI http client by 100k on Tuesday October 20, 2015 @01:18PM (#10420456)
I used to do this, but now I use jq. The thing about the Python version is that Python doesn't have ordered dictionaries, so the output isn't in the same order as the raw JSON. jq doesn't have that issue which is nice.
Re:Httpie: A CLI http client by batbomb on Tuesday October 20, 2015 @02:03PM (#10420723)
Python does have ordered dictionaries, but the json decoder defaults to regular dictionaries. This is easily overridable with JSONDecoder.
Re:Httpie: A CLI http client by 100k on Tuesday October 20, 2015 @02:47PM (#10420978)
Is there a one-liner you can use from the shell that preserves order?
Re:Httpie: A CLI http client by hnov on Tuesday October 20, 2015 @05:07PM (#10421820)
Starting with 3.5[0] that's the standard behavior.

One liner-wise, you could create an alias

  echo '{"foo":12, "bar": 11}' | python -c 'import json as j, collections as c, sys as s; j.dump(j.load(s.stdin, object_pairs_hook=c.OrderedDict), s.stdout, indent=4)'
[0] https://github.com/python/cpython/blob/3.5/Lib/json/tool.py#...
Re:Httpie: A CLI http client by agumonkey on Tuesday October 20, 2015 @10:40AM (#10419435)
jq is almost a full fledge programming language, like xquery, surprisingly powerful (in good and bad ways). Nice to port fragile sed-grep LoC.
Re:Httpie: A CLI http client by _Codemonkeyism on Tuesday October 20, 2015 @10:35AM (#10419395)
I often use jq to extract data from REST apis, e.g. email addresses I need in a CSV file.