Thursday 13 June 2024

format curl json response

 https://mkyong.com/web/how-to-pretty-print-json-output-in-curl/

 Pretty print JSON with json_pp

This json_pp is typically pre-installed on the Unix/Linux environment. It stands for JSON pretty print. It is less powerful than jq, but it does the job perfectly.

Terminal

curl -s https://api.cloudflare.com/client/v4/ | json_pp

{
   "errors" : [
      {
         "code" : 7000,
         "message" : "No route for that URI"
      }
   ],
   "messages" : [],
   "result" : null,
   "success" : false
}

No comments:

Post a Comment