When I display json on jbuilder, how can I indent it beautifully?

Asked 2 years ago, Updated 2 years ago, 99 views

I am currently creating an api with rails.
Therefore, I am using jbuilder, but when I checked with the browser, all the output results are side by side, so it is very difficult to see.
How can I indent it beautifully?
I'm sorry to trouble you, but I'd appreciate it if you could teach me

ruby-on-rails json api

2022-09-30 17:41

2 Answers

For development purposes, you can use browser add-ons.
(Example) JSONView: https://addons.mozilla.org/ja/firefox/addon/jsonview/


2022-09-30 17:41

Chrome also has
json-viewer
https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh
There is an add-on like this.If it's just for development, I think using add-on like this is quite different.

If you want to make it easier to see the result of hitting with a command line such as curl,
jq
https://stedolan.github.io/jq/
This tool is the major

 curl http://localhost:3000/api/v1/posts/|jq'.'

I think it will be easy to see if I give it to you like this

If you want to make it easy for users to see, it would be easy to understand that you can create a client or view that hits the api and make it beautifully shaped there...


2022-09-30 17:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.