Aug-29-2018, 06:22 PM
(Aug-29-2018, 07:06 AM)Winfried Wrote: Should I use another method than "dump"?Not sure because don't know where i goes wrong,don'not have file you use.
You should not use
f
in both read and dump.Here a example where i use a geojson file and put in
François
.import json from pprint import pprint with open('map.geojson' , encoding='utf-8') as f: data = json.load(f) pprint(data)
Output:{'features': [{'geometry': {'coordinates': [[8.9208984375, 61.05828537037916],
[9.84375, 61.4597705702975],
[10.7666015625,
60.930432202923335]],
'type': 'François'},
'properties': {},
'type': 'Feature'}],
'type': 'FeatureCollection'}
Dump data.import json with open("data_file.json", "w", encoding='utf-8') as f_out: json.dump(data, f_out, ensure_ascii=FalseContent of
data_file.json
.Output:{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "François",
"coordinates": [
[
8.9208984375,
61.05828537037916
],
[
9.84375,
61.4597705702975
],
[
10.7666015625,
60.930432202923335
]
]
}
}
]
}