Skip to content

Latest commit

ย 

History

History
42 lines (35 loc) ยท 1.36 KB

File metadata and controls

42 lines (35 loc) ยท 1.36 KB

Pretty Print JSON

python ์ด ๊น”๋ ค์žˆ๋‹ค๋ฉด console ์ฐฝ์—์„œ JSON ์„ ๋ณด๊ธฐ ์ข‹์€ ํ˜•ํƒœ๋กœ print ํ•  ์ˆ˜ ์žˆ๋‹ค.

Python Version ์€ 2.6 ์ด์ƒ ์ด์–ด์•ผ ํ•œ๋‹ค.

์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ณด๊ธฐ ์ข‹์€ ํ˜•ํƒœ๋กœ ๋ฐ”๋€๋‹ค.

echo 'YourJSONHere' | python3 -m json.tool

Example JSON

Code Reference from AWS CloudFormation

Before

{ "Resources" : { "HelloBucket" : { "Type" : "AWS::S3::Bucket", "Properties" : { "AccessControl" : "PublicRead", "WebsiteConfiguration" : { "IndexDocument" : "index.html", "ErrorDocument" : "error.html" } } } } }

Input Pretty Print Command

echo '{ "Resources" : { "HelloBucket" : { "Type" : "AWS::S3::Bucket", "Properties" : { "AccessControl" : "PublicRead", "WebsiteConfiguration" : { "IndexDocument" : "index.html", "ErrorDocument" : "error.html" } } } } }' | python3 -m json.tool

After

๊ฒฐ๊ณผ๋ฌผ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

{
    "Resources": {
        "HelloBucket": {
            "Type": "AWS::S3::Bucket",
            "Properties": {
                "AccessControl": "PublicRead",
                "WebsiteConfiguration": {
                    "IndexDocument": "index.html",
                    "ErrorDocument": "error.html"
                }
            }
        }
    }
}