Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

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
  • 0
    Certified Lead Developer

    Also, I would highly recommended that you use cleanWith() or your REGEX to whitelist the characters that are valid rather than blacklisting the invalid ones.  It's much more safe to go from that direction, because there's a whole host (over 100,000 at this point) of characters that could throw you off opposed to the 52 to 62 you'd probably want to keep.

Reply
  • 0
    Certified Lead Developer

    Also, I would highly recommended that you use cleanWith() or your REGEX to whitelist the characters that are valid rather than blacklisting the invalid ones.  It's much more safe to go from that direction, because there's a whole host (over 100,000 at this point) of characters that could throw you off opposed to the 52 to 62 you'd probably want to keep.

Children
No Data