티스토리 뷰

728x90
import json

your_json = '["foo", {"bar":["baz", null, 1.0, 2]}]'
parsed = json.loads(your_json)
print(json.dumps(parsed, indent=4, sort_keys=True))
[
    "foo", 
    {
        "bar": [
            "baz", 
            null, 
            1.0, 
            2
        ]
    }
]

https://stackoverflow.com/questions/12943819/how-to-prettyprint-a-json-file

 

How to prettyprint a JSON file?

I have a JSON file that is a mess that I want to prettyprint. What's the easiest way to do this in Python? I know PrettyPrint takes an "object", which I think can be a file, but I don't know how t...

stackoverflow.com

ourcstory.tistory.com/106

 

[Python] json 모듈 사용하기 :: String을 Dict으로 변환

들어가며 HTTP 통신을 하면서 data를 주고 받을 경우에 json형태로 데이터를 주고 받을 때가 많습니다. 또한 python에서는 dict의 type을 자주 사용하기 때문에 String을  dict으로 변환할 줄 알아야 하는

ourcstory.tistory.com

 

728x90

'공부' 카테고리의 다른 글

[Spark] SQL datediff  (0) 2020.08.11
[Java] convert integer to string with comma for thousands  (0) 2020.08.11
[Presto] month ago  (0) 2020.08.10
[Java] @JsonProperty show `is` prefix  (0) 2020.08.10
[Sh] for  (0) 2020.08.10
댓글