0

I have a JSON Array with the following structure:

  {
    "InvoiceNumber": "11111",
    "AccountName": "Hospital",
    "items": {
      "item": [
        {
          "Quantity": "48.000000",
          "Rate": "0.330667",
          "Total": "15.87"

        },
        {
          "Quantity": "1.000000",
          "Rate": "25.000000",
          "Total": "25.00"
        }
      ]
    }
  }
  

I would like to use Data Operation "Select" to select invoice numbers with invoice details.

Select:

From body('Parse_Json')?['invoices']?['invoice']

Key: Invoice Number;Map:item()['InvoiceNumber'] - this line works Key: Rate; Map: item()['InvoiceNumber']?['items']?['item']?['Rate']- this line doesnt work. The error message says "Array elements can only be selected using an integer index". Is it possible to select the Invoice Number AND all the invoice details such as rate etc.? Thank you in advance! Also, I am trying not to use "Apply to each"

Nataliia
  • 23
  • 6

1 Answers1

0

You have to use a loop in some form, the data resides in a array. The only way you can avoid looping is if you know that the number of items in the array will always be of a certain length.

Without looping, you can't be sure that you've processed each item.

To answer your question though, if you want to select a specific item in an array, as the error describes, you need to provide the index.

This is the sort of expression you need. In this one, I am selecting the item at position 1 (arrays start at 0) ...

body('Parse_JSON')?['items']?['item'][1]['rate']

Variable

Using your JSON ...

Result

You can always extract just the items object individually but you'll still need to loop to process each item IF the length is never a static two items (for example).

To extract the items, you select the object from the dynamic content ...

Items

Result ...

Result

Skin
  • 9,085
  • 2
  • 13
  • 29