Extraxt data from a json with more than one item in body

Newbie here. I use a webhook node to receive a list of customers with name, phone number e balance. Every time the web hook is called, the node might have 1 or more customers. I am trying to use the SET node to extract the customers’ info from the JSON to append to a Google Sheet.

I need the output in table format to be with name, phone number and balance as columns and the customer data as rows. How do I do that?

Hey @fxholl,

Welcome to the community :tada:

I think you may have asked about this on Discord as well, One solution for you would be to use an Item Lists node before the Set and set the option to Body then use the Set node after that.

HI jon, I did ask about this on Discord. I tried the List node but it did not help. Is it better to ask a follow-on question here or on Discord?

I now tried with another endpoint that does not use pagination, so the Json is simpler:

Still, the List node does not find the field “consumer_id” to aggregate

I tried the option All item Data into a single list but it doesn’t work like displayed in Item Lists - n8n Documentation

see my result:

Basically, I am able to use n8n to parse the output of the json when the endpoint returns one item, but not when the endpoint returns more than one item. Very frustrating.

Hi @fxholl

You need to use the itemlists node to split the items. (so changing the operation)
You need to split it on the data field.
After that your items will be the once that are inside the array. So each item will be one of the array objects.

I selected Split out function and the data (everything), but am getting an error “ERROR: Couldn’t find the field ‘[object Object],[object Object]’ in the input data”

Any suggestion?

I feel like it has to do with the fact that the json is nested, i am not sure.

you need to fill in the field name in this case “data” and not use the expression

It worked!! Thank you !!

2 Likes

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