如何在oracle中将xml转换为json? [英] How can i convert xml to json in oracle?

查看:901
本文介绍了如何在oracle中将xml转换为json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有

<xml><name>himasnhu</name><age>24</age></xml>  

我该如何隐瞒

{"name":"himanshu","age":24} .

谢谢.

推荐答案

在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.

这篇关于如何在oracle中将xml转换为json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆