How to write GET request content to a file with new lines instead of \n characters

I am trying to get an expression library from the Github API and save the content into a file in Snaplogic. When I get the content from the GET snap, it has \n characters and doesn’t recognize them as actual new lines. I then use the Width Formatter snap in order to get Snaplogic to recognize the \n characters as new lines. However, once I pass this into the File Writer snap, the file that was saved has no new lines, and the entire expression library is on one line.

Do you know how I can get Snaplogic to save the file with the new lines, formatted correctly?

@jmousavi - I think it comes as a single string . Try to use $response.split(\n").toString(). If not work share sample data.

If you are on Windows, try using \r\n in the Line Separator value of the Fixed Width Formatter. It may be that you’re trying to look at the file using a Windows-based editor and it is expecting the “carriage-return/line-feed” characters to indicate newline and it doesn’t understand the “line-feed” record terminator that is default on this snap.

I have tried both suggestions, but I am still having issues with Snaplogic recognizing new lines. Since I am making an Ultra task, I am no longer able to use the Fixed Width Formatter.

Here is an example of the content of the file I am getting from github:
object : {
source_1 : “website”,
source_2: “website”

After the getting the content from the Rest GET, this is what it looks like:
{\n object : {\n source_1 : “website”,\n source_2: “website”\n }\n}

I have also tried using the Json Formatter, but it still doesn’t recognize the \n as a new line, puts everything inside [ ], and also has quotes around the keys.

Can you parse the JSON?
JSON.parse(’{\n object : {\n source_1 : “website”,\n source_2: “website”\n }\n}’)

I am able to parse it, however it puts the keys in quotes and still doesn’t put any new lines in the file.
After running JSON.parse in the mapper, the output looks like this:
“object” : {
“source_1” : “website”,
“source_2”: “website”
After JSON formatter and file writer, the saved file looks like this:
{“object” : {“source_1” : “website”, “source_2”: “website” } }

Try checking the “Pretty Print” checkbox in the JSON Formatter. This should put the \n characters in.