deve_thomos
asked on
how to solve this query?
Hi expert,
below is my query
jsondata is given here :
Note:Note:inside 'vcvm' IF i give any special character . it will take a whole string it should not trim any characters
result:
1":{"YBG":1,"BNT":"vc{//}v m"},"2":{" YBG":1,"BN T":"vc}{
3":{"YBG":1,"BNT":"vc{
expected result:
1":{"YBG":1,"BNT":"vc}{//} vm
2":{"YBG":1,"BNT":"vc}{}}v m
3":{"YBG":1,"BNT":"vc}{}}v m
Regards
Thomos
below is my query
SELECT *
FROM (SELECT REGEXP_REPLACE(
REGEXP_SUBSTR(
:JSONdata,
'"[0-9]+".+?}}',
1,
LEVEL
),
'^[{"]+|[},]+&'
)
AS rec
FROM DUAL
CONNECT BY LEVEL <= 11)
WHERE rec IS NOT NULL;
jsondata is given here :
{"1":{"YBG":1,"BNT":"vc{//}}vm"},"2":{"YBG":1,"BNT":"vc}{}}vm"},"3":{"YBG":1,"BNT":"vc{}}vm"}}
Note:Note:inside 'vcvm' IF i give any special character . it will take a whole string it should not trim any characters
result:
1":{"YBG":1,"BNT":"vc{//}v
3":{"YBG":1,"BNT":"vc{
expected result:
1":{"YBG":1,"BNT":"vc}{//}
2":{"YBG":1,"BNT":"vc}{}}v
3":{"YBG":1,"BNT":"vc}{}}v
Regards
Thomos
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Missed that.
Let me work on it.
Let me work on it.
You had a typo from the solution in your previous question.
Based on the new requirement try this:
Based on the new requirement try this:
var JSONdata varchar2(100)
exec :JSONdata := '{"1":{"YBG":1,"BNT":"vc{//}}vm"},"2":{"YBG":1,"BNT":"vc}{}}vm"},"3":{"YBG":1,"BNT":"vc{}}vm"}}'
SELECT *
FROM (SELECT
REGEXP_REPLACE(
REGEXP_SUBSTR(
:JSONdata,
'"[0-9]+".+?"}',
1,
LEVEL
)
,
'^[{"]+|["}]+$'
)
AS rec
FROM DUAL
CONNECT BY LEVEL <= 11)
WHERE rec IS NOT NULL;
ASKER
Thanks a lot...
ASKER
see my expeceted output:
1":{"YBG":1,"BNT":"vc}{//}
2":{"YBG":1,"BNT":"vc}{}}v
3":{"YBG":1,"BNT":"vc}{}}v
your output:
1":{"YBG":1,"BNT":"vc{//}}
2":{"YBG":1,"BNT":"vc}{}}
3":{"YBG":1,"BNT":"vc{}}
After that all charecters 'vm' characters are missing.