0

I have a below JSON input coming from a source system:

{
   "d":{
      "results":[
         {
            "userId":"123",
            "employmentType":"Full time",
            "employment":{
               "compansation":{
                  "results":[
                     {
                        "payments":{
                           "results":[
                              {
                                 "payType":"Annual Salary",
                                 "value":"70000"
                              },
                              {
                                 "payType":"Annual Leave",
                                 "value":"1000"
                              },
                              {
                                 "payType":"Other Payments",
                                 "value":"2000"
                              }
                           ]
                        }
                     }
                  ]
               }
            }
         },
         {
            "userId":"456",
            "employmentType":"Full time",
            "employment":{
               "compansation":{
                  "results":[
                     {
                        "payments":{
                           "results":[
                              {
                                 "payType":"Annual Salary",
                                 "value":"80000"
                              },
                              {
                                 "payType":"Annual Leave",
                                 "value":"2000"
                              },
                              {
                                 "payType":"Other Payments",
                                 "value":"3000"
                              }
                           ]
                        }
                     }
                  ]
               }
            }
         },
         {
            "userId":"123",
            "employmentType":"Full time",
            "employment":{
               "compansation":{
                  "results":[
                     {
                        "payments":{
                           "results":[
                              {
                                 "payType":"Annual Salary",
                                 "value":"90000"
                              },
                              {
                                 "payType":"Annual Leave",
                                 "value":"3000"
                              },
                              {
                                 "payType":"Other Payments",
                                 "value":"4000"
                              }
                           ]
                        }
                     }
                  ]
               }
            }
         }
      ]
   }
}

I want to filter "employment/compansation/payments" to use "payType" "Annual Salay" and "Annual Leave" only; and filter out "payType: Other Payments". Then sum both "Annual Salary" and "Annual Leave" and generate final output like:

[
   {
      "userId":"123",
      "employmentType":"Full time",
      "totalSalary":"71000"
   },
   {
      "userId":"456",
      "employmentType":"Full time",
      "totalSalary":"82000"
   },
   {
      "userId":"789",
      "employmentType":"Full time",
      "totalSalary":"93000"
   }
]

Can I achieve this by only using native Logic App actions? Without using Functions or even JavaScript code? And how?

Victor McIntyre
  • 93
  • 1
  • 10

1 Answers1

0

You can use the "Filter Array" connector in Logic App.

This might be a duplicate question, with similar question being answered here.