简体   繁体   English

从json字符串oracle中提取

[英]extract from json string oracle

I have JSON string in a column like below. 我在下面的列中有JSON字符串。 oracle version - 12c oracle版本-12c

{
[
{
"Employee_id": 1
,"Salary":3206.93
}
]
}

How do I remove first flower brace and the square bracket.. 如何移除第一个花括号和方括号。

Result should look like below.. 结果应如下图所示。

    {
    "Employee_id": 1
    ,"Salary":3206.93
    }

Tried using regex like SELECT regexp_substr('"abc{[{def}]}ghi"', '\\[(.+)\\]') match FROM dual; 使用正则表达式(例如SELECT regexp_substr('"abc{[{def}]}ghi"', '\\[(.+)\\]') match FROM dual;

But it didn't work.. 但这没用..

select replace(replace(myColumn, '{[{', '{'), '}]}', '}')
from myTable

Note, this method will ONLY work if this column is always going to contain a single element of a JSON array, and if the JSON object doesn't contain any other JSON objects... otherwise it could break. 请注意,仅当此列将始终包含一个JSON数组的单个元素并且JSON对象不包含任何其他JSON对象时,此方法才有效...否则它可能会中断。 Use at your own risk :) 使用后果自负:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM