python json5 and json package inconsistent deal with surrogate pair

216 Views Asked by At
#!/opt/homebrew/bin/python3
#-*-coding:utf8-*-
#python version 3.11.4

import json5
import json

d = json5.loads('{"\\ud83d\\ude03": "ok"}')
print(d) # output: {'\ud83d\ude03': 'ok'}

d = json.loads('{"\\ud83d\\ude03": "ok"}')
print(d) # output: {'': 'ok'}

Is this a bug, a feature, or is my usage wrong?

surrogate pair is supported which described in this document: RFC 8259 - The JavaScript Object Notation (JSON) Data .... JSON5 is a superset of JSON,it should be compatible with json. so i think it's not a feature.

0

There are 0 best solutions below