Skip to content
Advertisement

Split the given column in oracle sql

I want to split the following table

column
{“senderName”:”John David”, “senderCountry”:”LKA”, “senderAddress”:”No 230,ABS,11200}

I want to get following table using oracle sql

senderName senderCountry senderAddress
John David LKA No 230,ABS,11200

I tried the following code

But I got the following table

senderName senderCountry senderAddress
“senderName” “John David”, “senderCountry” “LKA”, “senderAddress”

Anyone can help me?

Thank you

Advertisement

Answer

You should use JSON_TABLE for this.

If you cannot and your JSON is very simple (i.e. the keys are only going to appear once and you do not have a complicated path to parse) then you can use regular expressions (but don’t if you can use a proper JSON parser like JSON_TABLE):

Which, for the sample data:

Note: Your JSON was invalid as it is missing a closing ".

Outputs:

SENDERNAME SENDERCOUNTRY SENDERADDRESS
John David LKA No 230,ABS,11200
Jane Smith ABC No 42,”Home”, XYZ, 98765

db<>fiddle here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement