Replace special characters in JSON response

Hi guys,

We have an issue where an API push is failing because we are receiving JSON data and then pushing this data straight back out to the API. The API can output special characters but won't accept them. To get around this, we need to find a way to replace certain special characters from value fields with encoded characters. Example:

Received JSON:

{test1: "this is a test with some valid characters",

test2: "this is a test with some invalid characters , ! £"}

Pushed JSON:

{test1: "this is a test with some valid characters",

test2: "this is a test with some invalid characters .co .ex .po"}

So in this instance the aim would be to replace those special characters at the end of test2. 

Is there a way to do this, potentially with REGEX or a replace string? It would need to check all the value fields and replace any of the special characters in there with some encoding we've defined.

Thanks for any help.

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data