Bootstrap FreeKB - Python (Scripting) - Parse JSON using json.tool
Python (Scripting) - Parse JSON using json.tool

Updated:   |  Python (Scripting) articles

There are a number of different ways to parse JSON.

  • json.load - parse a JSON file
  • json.loads - parse JSON (key:value pairs)
  • json.dumps - get the json output of a dictionary
  • json.tool - parse JSON on the command line (this article)
  • .json() filter - parse JSON results

The python -m json.tool command can be used to produce human friendly JSON output on the command line.

~]$ echo '{ "foo": "Hello", "bar": "World" }' | python -m json.tool
{
    "bar": "World",
    "foo": "Hello"
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ef3040 in the box below so that we can be sure you are a human.