python-mysql-replication
python-mysql-replication copied to clipboard
MySQL JSON field type with string should decode in python3
Table:
CREATE TABLE test (id int, value json);
With data:
id | value |
---|---|
1 | {"string1":"string2"} |
But event's values in python3 is :
{"id":1,"value":{b"string1":b"string2"}
And when use json.dumps
will raise TypeError: keys must be a string
According to rfc7159 : https://tools.ietf.org/html/rfc7159#section-8.1
JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32. The default encoding is UTF-8
So should decode as utf-8