Pretty Print JSON Body
See original GitHub issueHow to pretty print a JSON output body in order to format it in bash console like
macbookproloreto:~ admin$ echo '{"foo": "lorem", "bar": "ipsum"}' | python -m json.tool
{
"bar": "ipsum",
"foo": "lorem"
}
My command looks like now
http --session=cookies.txt --pretty all --json --print=b --style=xcode "https://myapi.company.com | python -m json.tool
Does the option --pretty
aims to pretty print the output body? Having it seems to not prettify the output body, instead it prints the json as plain text
'{"foo": "lorem", "bar": "ipsum"}'
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Best JSON Pretty Print Online - JSON Formatter
JSON Pretty Print helps Pretty JSON data and Print JSON data. It's very simple and easy way to prettify JSON and pretty print...
Read more >Python Pretty Print JSON - DigitalOcean
We can use the Python json module to pretty-print the JSON data. The json module is recommended to work with JSON files.
Read more >How to prettyprint a JSON file? - python - Stack Overflow
Try to parse the JSON using json.loads() and pretty print that resulting dictionary. Or just skip to the Pretty printing section of the...
Read more >JSON Pretty Print using Python - GeeksforGeeks
First, use json.loads() method to convert JSON String to Python object. To convert this object to a pretty print JSON string, the json.dumps() ......
Read more >Pretty Print a JSON File in Python (6 Methods) - Datagy
How to Pretty Print a JSON File in Python · We load our file path to a file_path variable. · We then use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jkbrzt exactly. In fact the issue was that the server headers was
text/plain
while the body was a text formatted as a json body (well formatted json). Basically the response headerContent-Type
is notapplication/json
. CanHTTPie
force json formatting in those cases?HTTPie looks at the response
Content-Type
header. If it’stext/plain
, then it doesn’t do any special formatting. The URL you provided returnsContent-Type: application/json; charset=utf-8
so it gets properly formatted and highlighted as JSON.