norsk
norsk

Reputation: 55

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

Upvotes: 0

Views: 1697

Answers (2)

SwethaKandikonda
SwethaKandikonda

Reputation: 8234

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.

enter image description here

enter image description here

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

enter image description here

Upvotes: 2

rickvdbosch
rickvdbosch

Reputation: 15551

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.

Upvotes: 0

Related Questions