공부
[Python] pretty print JSON (string to dict)
승가비
2020. 8. 10. 22:33
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
[Python] json 모듈 사용하기 :: String을 Dict으로 변환
들어가며 HTTP 통신을 하면서 data를 주고 받을 경우에 json형태로 데이터를 주고 받을 때가 많습니다. 또한 python에서는 dict의 type을 자주 사용하기 때문에 String을 dict으로 변환할 줄 알아야 하는
ourcstory.tistory.com
728x90