JSON response formatting

I’m trying to built an API that uses different databases to show recent news articles. It’s nothing for client use, just trying it out for a couple of friends.

I’m looking for something that will help me visualize it a bit better in their console. They are new to all this technical stuff and I was searching for something to help them out.

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
December 30, 2022
Accepted Answer


I’m not sure I fully understand. Do you need to make it as a GUI or do you need them to see it in a terminal but sorted and sortable?

If you are looking for the latter, I’ll recommend using the JQ package. jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed , awk , grep and friends let you play with text. jq is written in portable C, and it has zero runtime dependencies

It sounds a lot harder than it is actually. Imagine you call your API with CURL or whatever you are using, you just need to pipe it with jq and that’s it.

Here is an example. Now, as I don’t have an actual JSON at hand, I’ll echo one for myself:

  1. echo '{"fruit":{"name":"apple","color":"green","price":1.20}}' | jq '.'
  2. {
  3. "fruit": {
  4. "name": "apple",
  5. "color": "green",
  6. "price": 1.2
  7. }
  8. }

Let’s assume you want to get only the name of the fruits:

  1. echo '{"fruit":{"name":"apple","color":"green","price":1.20}}' | jq
  2. "apple"

If you had more information in the JSON you would’ve seen more information in there.

Hope this helps!