Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: json类型字段提取值,两边多出引号
[Test Environment] TiDB
[TiDB Version] 5.7.25-TiDB-v5.0.4
[Reproduction Path] Operations performed to encounter the issue
CREATE TABLE test.city (
id INT PRIMARY KEY,
detail JSON
);
insert into test.city (id, detail) values(1, ‘{“name”:“Beijing”}’);
insert into test.city (id, detail) values(3, ‘[{“name”:“Beijing”},{“name”:“Shanxi”}]’);
[Encountered Issue: Phenomenon and Impact]
SELECT JSON_EXTRACT(detail, ‘$[1].name’) from test.city
JSON extraction includes quotes on both sides
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]