We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
A quick way to pretty-print JSON in Elixir is by using the Jason library.
You can install it by adding this to your dependencies:
{:jason, "~> 1.4"}
The next step it to have a variable with the JSON data you want to pretty-print:
json = """
{"hello": "world"}
"""
Pretty-printing then is a easy as:
pretty_printed_json = Jason.Formatter.pretty_print(json)
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.