Skip to content

json字段类型,json字符串的键存在特殊字符时,解析出来的值因为没有转义而无法插入目标库 #5127

@sx1313515

Description

@sx1313515
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

environment

  • canal version
    v1.1.17
  • mysql version
    8.0.29

Issue Description

当源库的json字符插入类似如下这种key包含特殊字符的数据时:
{"key1": {"(.)(/[^/]+\.(mp|MP)4)$": "value1"}}
这个值的key包括\转义符,解析出来的值会变成:
{"key1": {"(.
)(/[^/]+.(mp|MP)4)$": "value1"}}
这少了一个转义符\,导致插入目标库报错
nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Invalid JSON text: "Invalid escape character in string." at position XX in value for column

Steps to reproduce

Expected behaviour

{"key1": {"(.*)(/[^/]+\.(mp|MP)4)$": "value1"}}

Actual behaviour

{"key1": {"(.*)(/[^/]+.(mp|MP)4)$": "value1"}}

If there is an exception, please attach the exception trace:

Just put your stack trace here!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions