Skip to main content
Question

Cleaning Up String Formats, Specifically Working with Newline from JSON Parser

  • July 7, 2023
  • 1 reply
  • 286 views

Using Freshworks workflow, I am able to utilize the Web Request module using API calls to get me some JSON results.

Using the Parser module, I can grab a specific attribute. However, the data in this attribute is something like the following:

"### Title or Subject\n\n#### \n\nSection 1\n\nInformation about section 1 XXXXXXX \n\n#### Second 2\n\nInformation about section 2 XXXXXXXXXX”

How can I format this data nicely to add as a private note to a ticket, so that it looks something like this:

"### Title or Subject\n\n#### Section 1

Information about section 1 XXXXXXX

#### Second 2

Information about section 2 XXXXXXXXXX”

 

I believe I can use liquid filters to make this change, but looking at the documentation , I’m not sure how to approach it. I see newline_to_br is an option, but when attempting to use that, it didn’t format things correctly. I also tried splitting the text by ‘\n’, then iterating over it, but the text remains the same, just without the ‘\n’.

Any direction would be appreciated!

Did this topic help you find an answer to your question?

1 reply

zachary.king
Skilled Expert
Forum|alt.badge.img+16
  • Skilled Expert
  • 951 replies
  • November 30, 2023

Hello @johnnguyentran, perhaps you could use the expression node and take the results from the json parser to format the value. @Daniel Söderlund is a guru with the expression node and json parser. I am sure he would have a some really good insight.


Reply