Skip to main content

Hi,

 

Can anyone assist with the following issue? We have an automation process that extracts a string of text from a ticket, and then attempts to parse that text as a JSON object. While it works some of the time, I need an expression that will escape any double quotes, single quotes, and backticks.

For example (below), the text we receive in a ticket can include a password with double quotes, which causes the parse JSON to fail because the string isn't valid JSON. What I need is an expression that will either escape or remove any double quotes, single quotes, and backticks, allowing the text to be parsed as valid JSON.

Any help would be greatly appreciated!

 

 {
    "displayName": "John Doe",
    "givenName": "John",
    "surname": "Doe",
    "companyName": "Example Company Ltd",
    "employeeHireDate": "2024-01-01",
    "employeeId": "1234",
    "streetAddress": "123 Example St",
    "city": "Example City, Example State",
    "postalCode": "12345",
    "country": "XX",
    "jobTitle": "Software Engineer",
    "department": "Development - Main Office",
    "officeLocation": "Main Office",
    "accountEnabled": true,
    "mail": "john.doe@example.com",
    "mailNickname": "john.doe",
    "passwordProfile": {
        "forceChangePasswordNextSignIn": true,
        "password": "Password”123!"
    },
    "userPrincipalName": "john.doe@example.com"
}

Hi ​@KJC , I’ve used the replace function to edit placeholders before sending a call or after receiving a response and parsing the response. It would need to be done for each place holder so it can be a decent amount of work if it’s more than just the password you need to run through the expression. Here’s an example of an expression I built to remove commas and brackets from a placeholder. 


replace(replace(replace('{{P1.root.conversations.conversations_object.attachments.attachments_object.canonical_url.url1}}','.',''),']',''),'"','')

 


You could try to use liquid placeholders {{placeholder | escape}}. Maybe that helps in youur scenario.

Freshworks documentation links to that solution article: https://shopify.github.io/liquid/tags/control-flow/


Hi David,

Thank you for providing this information. I’m receiving it as plain text in the body of an email. Since I’m new to Fresh, Would you be able to confirm: does plain text in an email body mean there are no placeholders to target? If that’s the case, do you have an idea how I might target the password property within the plain text?

Many thanks


Hi,

 

Can anyone assist with the following issue? We have an automation process that extracts a string of text from a ticket, and then attempts to parse that text as a JSON object. While it works some of the time, I need an expression that will escape any double quotes, single quotes, and backticks.

For example (below), the text we receive in a ticket can include a password with double quotes, which causes the parse JSON to fail because the string isn't valid JSON. What I need is an expression that will either escape or remove any double quotes, single quotes, and backticks, allowing the text to be parsed as valid JSON.

Any help would be greatly appreciated!

 

 {
    "displayName": "John Doe",
    "givenName": "John",
    "surname": "Doe",
    "companyName": "Example Company Ltd",
    "employeeHireDate": "2024-01-01",
    "employeeId": "1234",
    "streetAddress": "123 Example St",
    "city": "Example City, Example State",
    "postalCode": "12345",
    "country": "XX",
    "jobTitle": "Software Engineer",
    "department": "Development - Main Office",
    "officeLocation": "Main Office",
    "accountEnabled": true,
    "mail": "john.doe@example.com",
    "mailNickname": "john.doe",
    "passwordProfile": {
        "forceChangePasswordNextSignIn": true,
        "password": "Password”123!"
    },
    "userPrincipalName": "john.doe@example.com"
}

So you get the string as JSON in an e-mail ?
There are placeholders for the description of the ticket. 

To replace or remove characters in placeholders you can use expression as ​@David Pietrs say.
You can also use remove – Liquid template language example {{placeholder | remove: “m”}} 
In the parser node you can change the type of the placeholder you get back, If it’s a array it has

  • Changing * to 0 will give you the first item. Then Typ from string/number array to string/number will give you back value without i ]. 
     


  • Hi David,

    Thank you for providing this information. I’m receiving it as plain text in the body of an email. Since I’m new to Fresh, Would you be able to confirm: does plain text in an email body mean there are no placeholders to target? If that’s the case, do you have an idea how I might target the password property within the plain text?

    Many thanks

    There one placeholder for the description. {{ticket.description}} 


    Reply