Home > OS >  Unicode decode mismatch on emojis when using json loads
Unicode decode mismatch on emojis when using json loads

Time:03-15

I have a list of utf-8 encoded objects such as :

test = [b'{"abc\xf0\x9f\x94\xa5\xf0\x9f\x91\xbd\xf0\x9f\xa7\x83": 123}',
 b'{"abc\xf0\x9f\xa7\x83": 234}']

and decode it as follows:

result = list(map(lambda x: json.loads(x.decode('utf-8','ignore')),test))

I notice that some emojis are not converted as expected as shown below:

[{'abc           
  • Related