Hey WeWeb community,
I’m trying to send data from WeWeb to another tool, but I’m stuck on how to build a dynamic array for the “positions” in Xentral’s API.
My source data from WeWeb might look something like this:
{
"id": 2005,
"positions": [
{
"id": 6443,
"artikel": 7851,
"bezeichnung": "GoDEX ZX1300i Thermotransferdrucker",
"menge": "1.0000",
"preis": "1659.00000000"
},
{
"id": 6444,
"artikel": 8958,
"bezeichnung": "GoDEX T10",
"menge": "1.0000",
"preis": "295.00000000"
}
// ... Possibly more positions
]
}
The format the other systems expects (simplified) is something like:
{
"customer": {
"id": "5"
},
"financials": {
"paymentMethod": {
"id": "5"
},
"currency": "EUR"
},
"positions": [
{
"product": {
"id": "7851"
},
"id": "6443",
"quantity": 1
},
{
"product": {
"id": "8958"
},
"id": "6444",
"quantity": 1
}
],
"date": "2025-01-21"
}
In WeWeb, I need a way to loop through each position (which can vary in number) and build that JSON array on the fly. Specifically:
id
in the Xentral positions should be taken frompositions[*].id
in WeWeb.quantity
in Xentral is the numeric version ofpositions[*].menge
.product.id
in Xentral should come frompositions[*].artikel
.
Any advice on how to set this up in WeWeb? Are there built-in ways or best practices (possibly using Collections, Loops, or data transformation) to map one array of objects to a new array that matches this structure? I’d love any workflows, screenshots, or tips you can share!
Thanks in advance!