I have a python script which writes JSON to a file with content that looks like this:
{
"album": "Night Hawk",
"album_artist": "Coleman Hawkins with Eddie \u201cLockjaw\u201d Davis",
"artist": "Coleman Hawkins with Eddie \u201cLockjaw\u201d Davis",
"bitrate": 744,
...
}
The file is uploaded to the server and processed with this:
with open(settings.JSON_UPLOAD_DIRECTORY + f.name, 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
This works without error on my MacOS development server. It has also worked for processing several thousands of files on my deployment server until now. Of a sudden I'm getting this error:
22. with open(settings.JSON_UPLOAD_DIRECTORY + f.name, 'wb+') as destination:
Exception Value: 'ascii' codec can't encode character '\u201c' in position 81: ordinal not in range(128)
I've read other posts about this here without coming to an understanding of what I'm doing wrong. I'm running Python3.6. My question is, do I need to adjust the statement that opens the in memory file for writing, or is there a problem with the encoding of the JSON file itself.