2016-11-26 80 views
-3

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

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 
+0

1)什么* “十进制数字符(112000)” *? 2)你正在从'DUAL'中选择,那么你指的是什么*“两列或更多的任何列和行”*? 'DUAL'恰好有一列和一列。 – Andreas

+0

根据要求,我想进入该 –

+0

您的评论是更没有意义的问题。进入*什么*?而你甚至没有回答我的第一个问题:什么*“十进制字符数”*? – Andreas

回答

0

这就是答案:

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;