[PYTHON] Easy JSON formatting with standard Linux functions

Introduction

Linux users, how do you format JSON when working with it on the console? JSON is often used in RESTful APIs, etc., and it is very convenient and you often see it, but if you use it without formatting, it will not be readable. So, I often use the jq command. However, this is not a Linux standard and may not be available in production. This time, I will introduce how to format JSON with only standard Linux functions.

Format JSON with standard Linux functions

Python is installed as standard on Linux, but *** JSON Module *** is one of the standard Python libraries. There is. Passing JSON data in a pipe makes it easy to format on the console.

$ echo '{"key1": "value1", "key2": {"key3": "value3"}}' | python -m json.tool
{
    "key1": "value1",
    "key2": {
        "key3": "value3"
    }
}

Let's JSON life!

Recommended Posts

Easy JSON formatting with standard Linux functions
JSON formatting
Linux standard textbook
Output log in JSON format with Python standard logging
Easy Grad-CAM with pytorch-gradcam
[Python] Use JSON with Python
Linux standard textbook memo 1
Linux standard textbook memo 3
Linux (Lubuntu) with OneMix3S
json parse with gdb
Linux standard textbook part 5
linux with termux app
Linux standard textbook part 4
Easy debugging with ipdb
Easy TopView with OpenCV