【问题标题】:json in Oracle 10 gOracle 10g 中的 json
【发布时间】:2016-11-26 16:08:44
【问题描述】:

我有 Oracle 10 g。 这是 json 的字符串:[{ "id": "1.00", "contactBy": "Rajesh Kumar"}, { "id": "2.00", "contactBy": "Rakesh Kumar"}]。 我可以同时获取两列和两行吗?

select regexp_replace(regexp_substr('[{"id": "1.00", "contactBy":"Rajesh Kumar"}
                                  ,{"id": "2","contactBy": "Emmanuel Test"}]'
                                  , '"contactBy":\s*("(\w| )")', 1, level)
                                  , '"contactBy":\s"((\w| ))"', '\1', 1, 1) contact 
from dual 
connect by regexp_substr('[{"id": "1","contactBy":"Rajesh Kumar"}
                       ,{"id": "2","contactBy": "Emmanuel Test"}]'
                       , '"contactBy":\s("(\w| )*")', 1, level) is not null

【问题讨论】:

  • 1) 什么“十进制字符数(112,000)”? 2) 您从DUAL 中进行选择,那么“任何列和行中的两个或多个” 指的是什么? DUAL 正好是一行一列。
  • 根据要求,我想参与其中
  • 你的评论比这个问题更没有意义。进入什么?你甚至没有回答我的第一个问题:什么“十进制字符数”
  • 根据要求,我想进入那个 id 联系人来自 1.00 Rajesh Kumar 2 Emmanuel Test
  • 对不起,我放弃了。我仍然不知道你想做什么。不,我不会“执行 sql 请求” 看看。如果您希望我们看到,请在问题文本中插入输出。请阅读“How do I ask a good question?

标签: json oracle plsql


【解决方案1】:

这就是答案:

select regexp_replace(regexp_substr('[{"id": "1.00", "contactBy":"Rajesh Kumar"},{"id": "2","contactBy": "Emmanuel Test+-"}]',
                                     '"contactBy":\s*(".*?")', 1, level),
                      '"contactBy":\s*"(.*?)"', '\1', 1, 1) contact, 
       regexp_replace(regexp_substr('[{"id": "1.00", "contactBy":"Rajesh Kumar"},{"id": "2","contactBy": "Emmanuel Test+-"}]',
                                     '"id":\s*(".*?")', 1, level),
                      '"id":\s*"(.*?)"', '\1', 1, 1) contact               
 from dual
 connect by regexp_substr('[{"id": "1","contactBy":"Rajesh Kumar"},{"id": "2","contactBy": "Emmanuel Test+-"}]', '"contactBy":\s*(".*?")', 1, level) is not null;

【讨论】:

    猜你喜欢
    • 2015-06-26
    • 1970-01-01
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 2010-09-16
    • 1970-01-01
    相关资源
    最近更新 更多