How to include Special characters in JSOn payload, without disturbing the format

anu57
Tera Contributor

I have a rest API integration in place when any change request created in Source will be created in Target instance as well when I put any value in Description field with special characters. for EX: " Creation of change "  OR " change is created 12#"

The JSON rejects it as the "'s and # is corrupting the format, is there a way to solve this. in Business Rule.

Description: " test created#$"

 

Expected result in target instance: "test created#$"

 

 

3 REPLIES 3

AirSquire
Tera Guru

Have you tried using setStringParameterNoEscape()?

Regards
Air

Hitoshi Ozawa
Giga Sage
Giga Sage

I'm not finding a problem with JSON not being able to process hash character. Following script works OK. Please provide a concrete JSON string as well as script that's being used.

var json = '{"Description": "test created#$"}';
var obj = JSON.parse(json);
gs.print(obj.Description);

Result

test created#$

Appli
Mega Sage
Mega Sage

Hi anu

You are correct, encoding is required to escape these symbols (by that it will convert characters into a format that can be transmitted over the Internet). Hope it helps

Hope it helps