简体   繁体   中英

Logic App - Expression to get a particular substring from a json

I have out form one of the tasks in Logic App:

{
"headers": {
    "Connection": "close",
    "Content-Type": "application/json"
},
"body": {
    "systemAlertId": "....",
    "endTimeUtc": null,
    "entities": [
        {
            "$id": "us_1",
            "hostName": "...",
            "azureID": "someID",
            "type": "host"
        },
        {
            "$id": "us_2",
            "address": "fwdedwedwedwed",
            "location": {
                "countryCode": "",
            },
            "type": "ip"
        },
    ], 
}
}

I need initialize some variable named resourceID that contains value someID which is read from above example.

Value someID will always be found in the first member of Entities array, in that case I guess need to use function first

Any idea how expression of Initial variable should look?

Thanks

Considering the mentioned data you are receiving from Http trigger, I have used Parse JSON in order to get the inner values of the mentioned JSON. Here is how you can do it.

在此处输入图像描述

在此处输入图像描述

and now you can initialize the resourceID using 'Initialise variable' connector and set its value to azureID as per your requirement.

在此处输入图像描述

Have a look at the Parse JSON action .

To reference or access properties in JavaScript Object Notation (JSON) content, you can create user-friendly fields or tokens for those properties by using the Parse JSON action. That way, you can select those properties from the dynamic content list when you specify inputs for your logic app. For this action, you can either provide a JSON schema or generate a JSON schema from your sample JSON content or payload.

With the information in the JSON available in an object, you can more easily access it.

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