The Below query is failing where the key name starts with [ampersand] @type. Is there a way to fetch the data without updating the Json key name in the table.
SELECT JSON_ARRAYAGG(JSON_OBJECT (
'id',JSON_EXTRACT(INV_MASTER, "$[0].id[0]") ,
'href',JSON_EXTRACT(INV_MASTER, "$[0].href[0]"),
'@type',JSON_EXTRACT(INV_MASTER, "$[0].@type[0]"),
'entityChar',JSON_EXTRACT(INV_MASTER, "$[0].entityChar")
))
as MASTER from PROFILE;
This seems to be mysql not allowing some special characters in the Json functions.
1条答案
按热度按时间pkwftd7m1#
No such problem. You use incorrect JSON paths simply.
Demo:
fiddle
Each quote type char must be used in proper place.
In the example above - the path is string literal which is quoted with single quotes (
'$[0]."@value"'
) whereas the value of the level in the JSON path in this string value ("@value"
) is quoted with double quotes.