python-mysql-replication icon indicating copy to clipboard operation
python-mysql-replication copied to clipboard

MySQL JSON field type with string should decode in python3

Open howmp opened this issue 6 years ago • 1 comments

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

howmp avatar Jul 10 '18 12:07 howmp

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

howmp avatar Jul 10 '18 12:07 howmp