Link to home
Start Free TrialLog in
Avatar of deve_thomos
deve_thomosFlag for India

asked on

How to make a generic function for json data in oracle ?

Hi expert,
on below query i am handling json. actually exactly i dont know which  special character handled by json and which one is not handled by json. so when i was entering data to this particular field , i have observed that these many characters are not supported by json , so i replaced this character like below. but exactly i donot know which is supported by json and which is not supported json. so i want a generic function , by which all special characters can handle by json.
 
   replace(replace(replace(emp_name,'\' , '\\\\' ),'''' , '\''' ),'"' , '\\"'  ) ;

Open in new window


for above things is working fine but problem is i dont know  how  many specail charecters are there like this which is not handle by  json. so i want to make a generic function with all special characters which can handle by JSON.

Regards
Thomos
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you check "utl_url.escape " and "utl_url.unescape"  to escape.
I am not 100% sure but this escape the URL 's but still can be used on any varchar2(4000) characters.
Avatar of deve_thomos

ASKER

below is my code
 I have handle for above json charecters but i am not getting idea how to handle hexadecimal digits(/U).
function rep(p_column_id  varchar2) return varchar2 as
begin
return replace(replace(replace(replace(replace(replace(replace(p_column_id, '\', '\\'), '"','\"'),
CHR(9),'\t'),CHR(8),'\b'),CHR(13),'\r'),CHR(12),'\f'),CHR(10),'\n');
end rep;

Open in new window


Regards
Thomos
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

I don't know a lot about JSON.

I can help with the regular expression once I understand the patterns.

What do they look like in JSON?
THANKS A LOT