Updated: 2018-07-29: Added a link to another online REST client and a JSON formatter to provide you with some additional options.
——————————————————————————-
Original Post:
Over the years I have worked with JSON (JavaScript Object Notation) to create various automation and or orchestration workflows which integrate with system providing a Representational State Transfer (REST) Application Programming Interface (API). This post will summarise the tools I use on a regular basis. Some of the figures in this blog post show up with really small text so please click them to review their content.
- curl – which is a command line tool for transferring data. See cURL wiki page for additional information. The curl command is available by default on Mac OS which is have used for the past 7 years.
- Postman – This is an UI based tool that “Helps you develop APIs faster” according to the product information. Anyway, it’s really easy to use.
- Python – No I’m not a python programmer but I intend to learn it in the future since I think it’s time to move on from the bash scrips I create on a regular basis 🙂 I’m using python to format the JSON output in a terminal (I use iTerm on my Mac). Just compare the output form the two curl command examples below where the first one does not use python to format the output but the second one does. The only thing you need to add to your curl REST API command is “| python -m json.tool”
This will make you appreciate the python magic quite a lot:)- Command “curl -k -u userXYZ -X GET –header ‘Accept: application/json’ ‘https://npx5.vcdx56.com:9440/PrismGateway/services/rest/v2.0/networks/’ gives the following output which is not that easy to read:
- Command “curl -k -u userXYZ -X GET –header ‘Accept: application/json’ ‘https://npx5.vcdx56.com:9440/PrismGateway/services/rest/v2.0/networks/’ | python -m json.tool” gives the following output which is pretty easy to read, change and reuse:
- Command “curl -k -u userXYZ -X GET –header ‘Accept: application/json’ ‘https://npx5.vcdx56.com:9440/PrismGateway/services/rest/v2.0/networks/’ gives the following output which is not that easy to read:
- JSON Validator JSONLint – This online JSON formatter/editor has helped me multiple times over the years to make sure the JSON code is actually correct.
- Pretty Print JSON – If you don’t have the option of formatting the JSON output you receive from a command you can past the output in the Pretty Print JSON online tool.
And yes I know there is a ton of useful tools out there but above are the once I use on a regular basis. Some other online tools are: