Hello, I receive the following data as JSON via POST webhook from parsio.io:
[
{
"headers": {
"host": "whatever",
"..."
},
"params": {},
"query": {},
"body": {
"mailbox_id": "619d0976b84dc20011f279c7",
"doc_id": "619d0d6db84dc20011f27fb6",
"event": "doc.parsed",
"payload": {
"template_id": "619d0ee7b84dc20011f27fdc",
"parsed": [
{
"name": "Supply",
"value": "Foo"
},
{
"name": "Number",
"value": "00xxxxxxx"
},
{
"name": "Date",
"value": "10/05/2021"
},
{
"name": "Address",
"value": "Street"
},
{
"name": "Amount",
"value": "0,71"
},
{
"name": "Due",
"value": "31/05/2021"
},
{
"name": "Supplier",
"value": "Foo"
},
{
"name": "received_at_date",
"value": "2021-11-23"
},
{
"name": "attachments_nb",
"value": 1
}
]
}
}
}
]
and try to send it to Airtable. I use set to define the fields I want to write. The problem actually is that inside set I need to access each field I need this way {{$json["body"]["payload"]["parsed"][X]["value"]}}
where X
is the position in the parsed[]
array. Thing is this position changes from request to request so I would like to access those values using key values. I’m trying to use function node before in order to map this in some way (this is just testing code):
// var keys = Object.keys($json["body"]["payload"]["parsed"]);
// var item = $json["body"]["payload"]["parsed"]
// const newArr = arr.map(obj => Object.values(obj));
// var keys = Object.keys(item.json);
// console.log(keys);
const data = items.map((item) => item.json);
return [
{
json: {
cells: data
// cells: keys
}
}
]
Any suggestions? Maybe I don’t even need to use the function node at all and just need to access {{$json["body"]["payload"]["parsed"][X]["value"]}}
in the correct way inside set node. Thanks