简体   繁体   中英

Logic Apps - looping through a nested array in JSON

I need to loop through this optional array (it's only the sectional of JSON I have trouble with).

As you can see from the code:

The optional bullseye has an array rings . rings has arrays of expansionCriteria and expansionCriteria may or may not have actions .

How do I iterate and get all type , threshold in expansionCriteria? I also need to access all skillsToRemove under actions , if available.

I am rather new to Logic Apps, so any help is appreciated.


        "bullseye": {
        "rings": [
          {
            "expansionCriteria": [
              {
                "type": "TIMEOUT_SECONDS",
                "threshold": 180
              }
            ],
            "actions": {
              "skillsToRemove": [
                {
                  "name": "Claims Foundation",
                  "id": "60bd469a-ebab-4958-9ca9-3559636dd67d",
                  "selfUri": "/api/v2/routing/skills/60bd469a-ebab-4958-9ca9-3559636dd67d"
                },
                {
                  "name": "Claims Advanced",
                  "id": "bdc0d667-8389-4d1d-96e2-341e383476fc",
                  "selfUri": "/api/v2/routing/skills/bdc0d667-8389-4d1d-96e2-341e383476fc"
                },
                {
                  "name": "Claims Intermediate",
                  "id": "c790eac3-d894-4c00-b2d5-90cd8a69436c",
                  "selfUri": "/api/v2/routing/skills/c790eac3-d894-4c00-b2d5-90cd8a69436c"
                }
              ]
            }
          },
          {
            "expansionCriteria": [
              {
                "type": "TIMEOUT_SECONDS",
                "threshold": 5
              }
            ]
          }
        ]
    }

Please let me know if you need more info.

To generate the schema, you can remove the name of the object at the top of the code: "bullseye":

Thank you pramodvalavala-msft for posting your answer in MS Q&A for the similar thread.

" As you are working with a JSON Object instead of an Array, unfortunately there is no built-in function to loop over the keys. There is a feature request to add a method to extract keys from an object for scenarios like this, that you could up vote for it gain more traction.

You can use the inline code action to extract the keys from your object as an array (using Object.keys() ). And then you can loop over this array using the foreach loop to extract the object that you need from the main object, which you could then use to create records in dynamics."

For more information you can refer the below links:

. How to loop and extract items from Nested Json Array in Logic Apps .

. Nested ForEach Loop in Workflow. .

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