Skip to content

json解析函数key中带有特殊关键字,比如(# . |)会出现无法解析的情况 #449

@413331861

Description

@413331861

测试例子如下:

MySQL [test]> select * from a;
+------+-----------------------------------+
| id | data |
+------+-----------------------------------+
| 2 | {"text.abc":"MXCHIP won a prize"} |
| 4 | {"text|abc":"MXCHIP won a prize"} |
| 1 | {"text_abc":"MXCHIP won a prize"} |
| 3 | {"text#abc":"MXCHIP won a prize"} |
+------+-----------------------------------+
4 rows in set (0.01 sec)

MySQL [test]> select get_json_string(data,'$.text_abc') from a;
+---------------------------------------+
| get_json_string(data, '$.text_abc') |
+---------------------------------------+
| NULL |
| NULL |
| MXCHIP won a prize |
| NULL |
+---------------------------------------+
4 rows in set (0.01 sec)

MySQL [test]> select get_json_string(data,'$.text.abc') from a;
+---------------------------------------+
| get_json_string(data, '$.text.abc') |
+---------------------------------------+
| NULL |
| NULL |
| NULL |
| NULL |
+---------------------------------------+
4 rows in set (0.01 sec)

MySQL [test]> select get_json_string(data,'$.text#abc') from a;
+---------------------------------------+
| get_json_string(data, '$.text#abc') |
+---------------------------------------+
| NULL |
| NULL |
| NULL |
| NULL |
+---------------------------------------+
4 rows in set (0.01 sec)

MySQL [test]> select get_json_string(data,'$.text|abc') from a;
+---------------------------------------+
| get_json_string(data, '$.text|abc') |
+---------------------------------------+
| NULL |
| NULL |
| NULL |
| NULL |
+---------------------------------------+
4 rows in set (0.01 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions