13

I am trying to do this:

curl localhost:3000/api/items/15/tools

This is the return right now:

{"recipe_tools":[{"id":19,"name":"Cutting Board","prices":{"display":"$49.99","value":"49.99"},"description":"Built to last,
... (and then like a million lines)

And it keeps going...

How do I pretty print or awesome print this? What can I do?

Jwan622
  • 9,962
  • 16
  • 68
  • 147
  • Within `curl`? You can't; it doesn't. There are _plenty_ of tools you could pipe some JSON into and format it though. As such, I would suggest this is actually a software recommendation request. – Sobrique May 05 '16 at 20:40
  • You learn how to parse the object that is returned. – durbnpoisn May 05 '16 at 20:40
  • Possible duplicate of [How can I pretty-print JSON from the command line? (from a file)](http://stackoverflow.com/questions/20265439/how-can-i-pretty-print-json-from-the-command-line-from-a-file) – dafyk May 05 '16 at 20:41
  • What's your scripting language? – Mojtaba May 05 '16 at 20:59

2 Answers2

18

There are things you can install... but the simplest way is to use python as its typically already installed.

curl localhost:3000/api/items/15/tools | python -m json.tool

Grimnoff
  • 350
  • 2
  • 9
2

Port 3000 makes me think you are using Rails.

I have used JSON.pretty_generate(json_obj) on my RoR applications to have a JSON object return properly indented.