# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import json
dict = {"hello": "japanisch"}
text = json.dumps(dict, sort_keys=True, ensure_ascii=False, indent=2)
with open("utf8.json", "w") as fh:
fh.write(text.encode("utf-8"))
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
import json
with open("utf8.json") as fh:
js = json.loads(fh.read(), "utf-8")
print(js["hello"])
Recommended Posts