简体   繁体   中英

Logic Apps - Json Arrays and Response

Please help. What I am trying to achieve is providing a Logic App back end to an API.

The API is to look up values within database to generate a quote.

The flow is to look up a service to see if we have an active service. If so, it then looks up the selling rates and cost rates for that service.

The sell rate is based on the cost rate so need to retrieve both and supply in response to work out the sell rate.

在此处输入图像描述

For Each Service I am getting the Selling Charges then for each Selling Charge I am getting the rate calculation

I am appending to array. However, my outcome is:

[
  {
    "ChargeCode": "Carge2",
    "ChargeDescription": "",
    "ChargesCalculation": [
      {
        "base": null,
        "break": null,
        "calculationType": "COS",
        "currency": "GBP",
        "max": null,
        "min": null,
        "rate": 1000
      }
    ],
    "CostsCalculation": [
      {
        "base": null,
        "break": null,
        "calculationType": "CTN",
        "currency": "USD",
        "max": null,
        "min": null,
        "rate": 27000
      }
    ],
    "Currency": "USD"
  }
]

[
  {
    "ChargeCode": "Charge1",
    "ChargeDescription": "",
    "ChargesCalculation": [
      {
        "base": null,
        "break": null,
        "calculationType": "FLT",
        "currency": "GBP",
        "max": null,
        "min": null,
        "rate": 50
      }
    ],
    "CostsCalculation": [
      {
        "base": null,
        "break": null,
        "calculationType": "CTN",
        "currency": "USD",
        "max": null,
        "min": null,
        "rate": 27000
      }
    ],
    "Currency": "USD"
  }
]

The second loop has no costs so just need a blank array rather than copying the same amount

The following is the input data that I have taken for demonstration.

在此处输入图像描述

I could able to achieve your requirement following the below flow.

在此处输入图像描述

Results in array Variable

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM