Question

How to encode

  • 15 August 2023
  • 3 replies
  • 37 views

Badge +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

Userlevel 7
Badge +20

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

Badge +1

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?

Userlevel 7
Badge +20

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