I’m trying to understand how to use JSON paths to simplify extracting selected data from long JSON strings. I created a very simple table with just 1 field (invoiceData) to contain the JSON…
{
“Invoice”: {
“Amount”: 250,
“Number”: “INV0001”
}
}
I then created a simple codeless api to try and return the information but when run it completes ok but returns no data and I can’t work out why.
Hi @Duncan_Hughes ,
For “Get property” block you need to use simple path format instead of JSON paths. In case from image path will be “Invoice” if you want to extract whole invoice object and “Invoice.Amount” in case if you want to extract “Amount” field of invoice.
Regards, Andriy
1 Like
Hi @Andriy_Konoz
Thanks for taking the time to reply. I tried changing “Get property” to Invoice.Amount but it still returns nothing.
@Duncan_Hughes ,
Are you sure that “Get object from the table” block returns JSON which you mentioned in your first message?
I based my answer on that JSON Structure.
Regards, Andriy
1 Like
Hi @Andriy_Konoz
Ah… I should have preceeded it with the column name invoiceDate. It now works as expected…
Thanks for your help.
1 Like
@Andriy_Konoz
One last thing - What do I need to do if the JSON contains an array, e.g.
{
"Invoice": [
{
"Amount": 250,
"Number": "INV0001"
},
{
"Amount": 350,
"Number": "INV0002"
}
]
}
I tried InvoiceData.Invoice[0].Amount but that didnt return anything…
@Andriy_Konoz
I worked out the solution by trial and error! Instead of [0] it needed to be .0. (to return the first item in the array). So the “Get property” needed to be invoiceData.Invoice.0.Amount