是否可以将 JSON_EXTRACT
与整数键一起使用?
我想从下面提取 [273, 140]
,但是 SQL 不起作用 ...
SELECT json_extract('{"1": [273, 140], "2": [273.5, 198.5], "3": [209, 191]}', '$.1');
我正在尝试使用 https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html#operator_json-column-path 中的语法
我得到错误:
ERROR 3143 (42000): Invalid JSON path expression.
The error is around character position 3
最佳答案
如果是数字,您应该在键周围使用双引号。这有效:
select json_extract('{"1": [273, 140], "2": [273.5, 198.5], "3": [209, 191]}', '$."1"');
关于mysql - 有没有办法将 MySQL 的 JSON_EXTRACT 与 JSON 字符串中的整数键一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48468499/