Formatting cURL Output in the Windows Terminal
Solution 1:
Its an old question but I want to answer in total's simple context.
- Install Node.Js (Optional) - If you do not have Node js then download the LTS Version of Node JS (you can even install latest if you want)
- After Installation (or if you already have node js install then just for confirmation type
node -v
andnpm -v
. - Both should return a proper version numbers as shown below
- Once you are done with installation confirmation then go ahead and install global version (using -g) flag of jsontool lib on node.
npm install -g jsontool
- Once you are done with the installation in previous step then simply use the pipe | json in last line of curl request.
- Output without json pipe
- Output with json pipe
Solution 2:
Not exactly, but here's a Python script that improves on that.
import urllib2
import simplejson
import pprint
URL = "http://www.documentcloud.org/api/search.json?q=group:nytimes"
def showfeed(argv):
argv[1] if len(argv) > 1 else URL
fo = urllib2.urlopen(URL)
obj = simplejson.loads(fo.read())
pprint.pprint(obj)
if __name__ == "__main__":
import sys
showfeed(sys.argv)