How to Pretty Print JSON output in cURL
In cURL requests, the default JSON output is in compact format.
Terminal
curl https://api.cloudflare.com/client/v4/
{"success":false,"errors":[{"code":7000,"message":"No route for that URI"}],"messages":[],"result":null}
In cURL, we can use or pipe the json_pp
to pretty print the JSON output.
Terminal
curl https://api.cloudflare.com/client/v4/ | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 104 0 104 0 0 400 0 --:--:-- --:--:-- --:--:-- 398
{
"errors" : [
{
"code" : 7000,
"message" : "No route for that URI"
}
],
"success" : false,
"result" : null,
"messages" : []
}
Well, you made my day. I have been playing around with Python modules to do this because I did not know about json_pp. Thanks so much sir. Have a great day.
B
json_pp for the win. Thanks mkyong.
Thank you Mkyong!
Good to know it helped.
Thanks mkyong