我正在尝试将 JSON 数据解析到 oracle 中的不同列。下面是我正在运行的sql。我无法确定为什么会出现 json 解析错误。我尝试替换非 ASCII、不可打印的字符,但它仍然不起作用 -
select * from (select '{
"data": [
{
"note": "Yeah, it still wonb\u00000019t let me. Not sure why.\r\n\r\nThanks man!\r\n\r",
"id": 0
}
]
}' json_data from dual)i ,json_table( i.json_data , '$.data[*]'
COLUMNS (
ID varchar2(4000) path '$.id',
note varchar2(4000) path '$.note'
) )
select *
from (select '{'||chr(10)||
' "data": ['||chr(10)||
json_object(key 'note' value 'Yeah, it still won''t \\u00000019 let me. Not sure why.'
,key 'id' value 0)||
' ]'||chr(10)||
'}' json_data
from dual) i
, json_table(
i.json_data
, '$.data[*]'
columns(
id varchar2(4000) path '$.id'
, note varchar2(4000) path '$.note'));
hth (顺便说一句,我在 Oracle 19 上测试了这个查询)