Create a list of data with Json

Hi,

I get this data from an API. I will need to separate the “number” value into a list.

2022-02-20 at 22.37.06

I have tried to do this with the List node but I can’t get it to work.

Do you have a solution for me?

Thanks for your help.

Use a function node with the following code:

const data = items[0].json.body.Number.split(‘,’);

return data.map((d) => ({ json: { number: d } }))

Example workflow
3 Likes

Thanks for your help.

I tested this solution and I get this error message. I must have made a mistake on something simple…

Thanks for your help :slight_smile:

2022-02-21 at 07.58.47

Hey @Lyoto, the example provided by @RicardoE105 is working for me as expected:

image

Have you tried copying the example workflow’s JSON snippet right into your n8n canvas? This should prevent any unexpected characters from sneaking in :slight_smile:

@RicardoE105 @MutedJam Thank you for your messages.
I tried to isolate the number part via a SET but I still have the same problem.

I probably made a mistake somewhere but I don’t see where. Do you have an idea?

Thanks :slight_smile:

2022-02-21 at 19.27.15


2022-02-21 at 19.28.07
2022-02-21 at 19.27.52

Hi @Lyoto,

can you send your workflow node as JSON? Select the node → STRG + C (to copy) and past it here?

Your screenshot show a wrong type of quotation marks in *.split(','). For JavaScript you have to use some of this:
grafik
'value' or "value" or `value`

RicardoE105 use the right marks in his post.

In the example I sent you, there is no set node. Connect the webhook node directly to the function node.

I just looked and the problem was with the type of quotation marks. I don’t know why the copy and paste didn’t go well.

@RicardoE105 @BillAlex @MutedJam Thank you very much for your help :pray: :slight_smile:

1 Like

Excellent, glad to hear it’s working now. Thanks so much for confirming!