且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在oracle中将xml转换为json?

更新时间:2023-01-23 08:27:16

在Oracle 12.2中,您应该可以使用:

In Oracle 12.2 you should be able to use:

SELECT JSON_OBJECTAGG( id VALUE text )
FROM   XMLTABLE(
         '/xml/*'
         PASSING XMLTYPE( '<xml><name>himanshu</name></xml>')
         COLUMNS id   VARCHAR2(200) PATH './name()',
                 text VARCHAR2(200) PATH './text()'
       );

我不在12c系统上,因此未经测试.

I'm not on a 12c system so this is untested.

在早期版本中,您可以编写Java函数 [1] Java JSON软件包之一 >执行转换,然后使用 loadjava实用程序(或 CREATE JAVA语句),然后使用它.

In earlier versions you can write a Java function [1] [2] using one of the many Java JSON packages to perform the conversion and then load it into the database using the loadjava utility (or a CREATE JAVA statement) and then use that.