How to format a input to something else

Yeah, the title isn’t very useful I know.

I am trying to break out this input into fields based on the line breaks is that possible?

image

You can use the Code node to do that:

$input.first().json.messages = $input.first().json.message.split('\\n')
1 Like

Did I do this wrong?

Hello @JayManCanada,

The code depends on the structure of your input data.
Could you post the json you use as input?

Thanks!

{{$json[“body”][“message”]}}

Not sure if you seen my response {{$json[“body”][“message”]}}

Hello @JayManCanada,


Here is a screenshot of the result obtained with the solution I propose:


Here is the workflow


And here is the code

const input = $input.all();
const message = input[0].json.body.message;
const result = message.split("\n").map(el => el.trim());

return {result};

Hope it helps!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.