Remove Line Break using the Expression area

Hi there,

I’m using expressions to read data from another node, for an HTTP Request node that will POST.

Since the string received contains some line breaks (text with paragraphs) it is breaking the JSON.

Please, is there a method or what do you suggest to insert in the Expression itself to “replace line breaks with a space” or something similar?

Thank you

Replacing newlines in the expression can be done like this:

{{$node["XLS_Rows"].json["Description"].replace(/\n/g, " ")}}

But I would build the object completely in the expression (Javascript), that way you don’t need to worry if the input will break the JSON. You could do that like this:

{{ {business_unit: "", description: $node["XLS_Rows"].json["Description"]} }}

You might have to do JSON.stringify for the resulting object depending on your needs.


That worked, thank you so much.

I’ve just changed it to