从Oracle存储过程生成JSON

时间:2020-03-09 14:44:20

标签: json oracle stored-procedures

我想从Oracle存储过程生成JSON对象。有什么办法吗?

有没有开源库?

我检查了this,看起来它只是来自SQL的未存储过程

1 个答案:

答案 0 :(得分:0)

您的数据库中可能已经安装了APEX_JSON package(Oracle APEX附带)。

例如(来自链接的文档):

BEGIN
    apex_json.open_object;        -- {
    apex_json.write('a', 1);    --   "a":1
    apex_json.open_array('b');  --  ,"b":[
    apex_json.open_object;    --    {
    apex_json.write('c',2); --      "c":2
    apex_json.close_object;   --    }
    apex_json.write('hello'); --   ,"hello"
    apex_json.write('world'); --   ,"world"
    apex_json.close_all;          --  ]
                          -- }
END;