I am writing a JSON file, as string input, using python, into a .json file in the file system.
However I am getting the following error sometimes and I don’t know why.
Any ideas?
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’xe4′ in
position 1920: ordinal not in range(128)
The json file created is used as input in the “JSON To Features” geoprocessing tools and it fails.
# Script arguments
inputFeatures_json = arcpy.GetParameterAsText(0)
#write to file
jsonFileName = 'WebMap_{}.json'.format(str(uuid.uuid1()))
JSON_File = os.path.join(arcpy.env.scratchFolder, jsonFileName)
f = open(JSON_File , 'w')
f.write(inputFeatures_json)