question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pretty Print JSON Body

See original GitHub issue

How 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:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
loretoparisicommented, Jan 4, 2016

@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 header Content-Type is not application/json. Can HTTPie force json formatting in those cases?

0reactions
jakubroztocilcommented, Jan 3, 2016

HTTPie looks at the response Content-Type header. If it’s text/plain, then it doesn’t do any special formatting. The URL you provided returns Content-Type: application/json; charset=utf-8 so it gets properly formatted and highlighted as JSON.

screen shot 2016-01-03 at 6 58 33 pm

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found