Formatting cURL Output in the Windows Terminal

Solution 1:

Its an old question but I want to answer in total's simple context.

  1. 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)
  2. After Installation (or if you already have node js install then just for confirmation type node -v and npm -v.
  3. Both should return a proper version numbers as shown below

Snapshot of Node js and Npm Version Numbers

  1. 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

json tool npm installation

  1. Once you are done with the installation in previous step then simply use the pipe | json in last line of curl request.
  2. Output without json pipe without json pipe
  3. Output with json pipe output pretty 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)