plsql - 更改使用 APEX_JSON 解析的 JSON 对象
问题描述
我希望能够更改使用 APEX_JSON.parse()函数解析的 JSON 对象,但我在官方文档中一无所获,也没有关于此的提示或示例。
在下面的代码中,我在特定点中添加了注释,以便清楚地了解我的需求。
SET SERVEROUTPUT ON
DECLARE
j apex_json.t_values;
l_paths apex_t_varchar2;
writers clob;
json_object_result clob;
BEGIN
writers := '[
{
"id": null,
"hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f",
"description": "Machado de Assis",
"base64Img": "8eNZ28Dh5rZQIPhNEfwqoo1LCVx..."
},
{
"id": 151,
"hashCode": "a8f15eda80c50adb0e71943adc8015cf",
"description": "José Alencar",
"base64Img": "/XIQIHCol8eNZ28Dh5rZQIPhNEfwqoo1LCVx/9k=..."
}
]';
apex_json.parse(j, writers);
l_paths := apex_json.find_paths_like (
p_values => j,
p_return_path => '[%]',
p_subpath => '.hashCode',
p_value => '7ef605fc8dba5425d6965fbd4c8fbe1f'
);
dbms_output.put_line('Itens found: ' || l_paths.count);
if (l_paths.count = 1) then
dbms_output.put_line('id: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.id'));
dbms_output.put_line('hashCode: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.hashCode'));
dbms_output.put_line('description: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.description'));
dbms_output.put_line('base64Img: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.base64Img'));
-- Here I would like to nullify base64Img attribute value
json_object_result := 'here goes the object matched in the search with the base64Img attribute value null';
end if;
END;
在我的json_object_result
变量中,我想保存apex_json.find_paths_like()
与它的base64Img
属性 null 匹配的 JSON 对象。在我的示例中,结果将是
{
"id": null,
"hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f",
"description": "Machado de Assis",
"base64Img": ""
}
或者
{
"id": null,
"hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f",
"description": "Machado de Assis"
}
有可能用 做类似的东西APEX_JSON
吗?
解决方案
推荐阅读
- javascript - 如何在 chrome 扩展的 manifest v3 中使用 background.html
- ruby - Ruby 变量未在循环中读取
- macos - 视觉工作室代码智能感知不工作(mac)
- python - 从 Sympy 加速自动换行
- laravel - 我们可以在 laravel eloquent 中使用 update() 和 find() 吗?
- flutter - 无法在 JSON 正文中使用 TextEditingController 变量发布 http 请求
- java - 如何在 Java 的 GUI 程序中使用几个多维数组和一维数组?
- android - 使用 ffmpeg 将两个视频与其原始音频连接起来?
- python - Python子进程popen scp触发远程主机上的sshd,当scp完成时不会自动停止
- function - 绘制星星的对象方向