Skip to main content
Question

How to encode


Forum|alt.badge.img+1
  • Do Gooder (Customer)
  • 1 reply

Hi, 

I’m trying to set up a event action. I call a REST endpoint from my event action.

I try to format my POSTed message as json. How can invalid characters, like {} “, in my data be handled? Is there a function for escaping texts?

Thank you!

3 replies

dsj
Ultimate Hero (Partner)
Forum|alt.badge.img+22
  • Ultimate Hero (Partner)
  • 865 replies
  • August 15, 2023

Hi @ErikZ 

 

curly braces don’t need to escape in json payload. Double quotes can be escaped with \. do you have an example message with invalid characters?

 

Cheers!

Damith


Forum|alt.badge.img+1
  • Author
  • Do Gooder (Customer)
  • 1 reply
  • August 15, 2023

Hi @dsj,

the body defined for my POST looks like this,

{"tasknr" :"&OLD:TASK_SEQ", "descr" : "&NEW:DESCRIPTION"}

If description contains double quotes then the json is not valid I suppose. Is there a function I can use to escape NEW:DESCRIPTION?


dsj
Ultimate Hero (Partner)
Forum|alt.badge.img+22
  • Ultimate Hero (Partner)
  • 865 replies
  • August 15, 2023

Have you tried the Oracle REPLACE function

Eg:

select REPLACE ('My text with "doublequotes"', '"', '\"') from dual

 

Haven’t tested below but hope it works :) 

json_ := '{"tasknr" :"&OLD:TASK_SEQ", "descr" : "' || REPLACE(&NEW:DESCRIPTION, '"', '\"') || '"}';

 

/Damith


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings