I poll customer orders from a web service that looks like this:
"Endereco":"RUA REJANE FREIRE CORREIA",
I need to create another JSON that has the same structure but with diferent names for each variable. For exemplo “Data” will be sent as “sale_date”.
I started using SET node, but I am unsure how to transform de nested part for products (“Itens”):
I don’t know any JS, can someone help?
Information on your n8n setup
n8n version: 0.198.2
Database you’re using (default:): SQLite
- Running n8n with the execution process [own(default), main]:
Running n8n via [Docker, npm, n8n.cloud, desktop app]: desktop app
I now tried to add an array as aditional value in Set, but is treating the variables as values and not variables
you can use the item lists node to retrieve those nested items.
ok, but how do I insert them again in the final Json?
Right now I have this workflow:
Here is the output from Set node:
You can keep the other fields.
It all depends on what your output needs to be.
@BramKn the output needs to be an array with the same product information, with different labels.
For instance, if in the input Json it says
Quantidade : 3
the output Json needs to become:
I tried to map the variables in an expression, but it is not working:
So you want the same format just other field names within the array?
Then I think you have 2 options.
- use a function node to go through all the array items and change the names.
- split the array rename the fields and then aggregate the items back into the array. might need a split in batches=1 for that to make it easy to work with.
@BramKn that’s correct. Is either option possible for someone without JS coding experience or skill?
the second would be just using n8n nodes.