Json format for API Documint to generate PDF files from table

Hi i got a question, im using documint to generate PDF from table and query

the generation works but as im generating invoice with several items, in request im sending this:

{
"ref_no":"ddu91945",
"product_list": [
{"name":"{{ listaPurchaseLines.dataArray['0'] }}", "quantity": "{{ listaOC.dataArray['0'].po_qty_remaining }}"}
]
}
but i need to send the same structure

{"name":"{{ listaPurchaseLines.dataArray['0'] }}", "quantity": "{{ listaOC.dataArray['0'].po_qty_remaining }}"}

for each product

so if invoice have 5 items i should send in body to API

   {"name":"{{ listaPurchaseLines.dataArray['0'] }}", "quantity": "{{ listaOC.dataArray['0'].po_qty_remaining }}"}

5 lines like this

i tried to use the following

in this example i got 2 items

the request to api should be like this

{
"ref_no":"ddu91945",
"product_list": [
{"name":"{{ listaPurchaseLines.dataArray['0'] }} THIS IS PRODUCT 1", "quantity": "{{ listaOC.dataArray['0'].po_qty_remaining }}"},
{"name":"{{ listaPurchaseLines.dataArray['0'] }} THIS IS PRODUCT 2", "quantity": "{{ listaOC.dataArray['0'].po_qty_remaining }}"}
]
}

i had tried the following transformer:

but it shows json incorrectly

this is my table, any help will be appreciate it @Kabirdas @victoria @bradlymathews @ScottR any tips? :slight_smile:

thank you

Hey @agaitan026!

If you're just looking to generate an array I would try using map! Does something like this work?

const categorizedData = yourDataArray.map((row) => ({name: row.name, quantity: row.quantity}));
1 Like

i tried that but it add some brackets

`

{"ref_no":"ddu91945","product_list":[{"name":["MERCURSYS MW305R / ROUTER INALAMBRICO 300MBPS / 3X ANTENA"],"quantity":[10]}]}

`

like: ["MERCURSYS MW305R / ROUTER INALAMBRICO 300MBPS / 3X ANTENA"]

those should not be there

my bad

const categorizedData = formatDataAsArray({{ listaPurchaseLines.data }}).map((row) => ({name: row.name, quantity: row.quantity}));

return categorizedData;

i had to set formatDataAsArray(mydata)

now it works perfect

thank you