I want to be able to view the file in the editor and see an automatically ü.
# -*- coding: utf-8 -*-
import json
from collections import OrderedDict
fdata = OrderedDict()
fdata[u"Züge"] = 0
fdata[u"Bahnhöfe"] = 0
with open("Desktop/test.json", "w") as outfile:
json.dump(fdata, outfile, indent=2, ensure_ascii=False)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 2: ordinal not in range(128)
It has something to do with OrderedDict, with a normal dict it works.