what will be the easiest way to retrive the "HydraulicPressure" and "FailedPickupsLastHr" values from the below json in logic app?
{
"variables": [
{
"name": "sensorarray",
"type": "String",
"value": "{"ContentData":{"applicationId":"0db2345","deviceId":"178","enqueuedTime":"2022-09-17T14:27:22.386Z","enrichments":{},"messageSource":"properties","messageType":"devicePropertyReportedChange","properties":[{"name":"FailedPickupsLastHr","value":42},{"name":"HydraulicPressure","value":30.863390107917837}],"schema":"default@v1","templateId":"dtmi:z"},"Properties":{"iotcentral-application-id":"05","iotcentral-message-source":"properties","iotcentral-message-type":"devicePropertyReportedChange","iotcentral-device-id":"1q9hn5l4xcl","x-opt-sequence-number":5663,"x-opt-offset":"5307784","x-opt-enqueued-time":"2022-09-17T14:27:28.046Z","message-id":{"EncodeSize":38},"group-sequence":0},"SystemProperties":{"EnqueuedTimeUtc":"2022-09-17T14:27:28.046Z","Offset":"5307784","PartitionKey":null,"SequenceNumber":5663}}"
}
]
}
2
Answers
I have reproduced in my environment, you can similarly do it for your json array as below:
Firstly, select initialize variable step and then set it with below json example :
Then, select the SELECT step
And then select the varaible you want from array and then get it with using item as below:
Output:
Try to update your array as the given example and try the above steps you will get the output as above.
Load this definition as a new LogicApp into your tenant …
It will give you my answer in full and show you how to get to the values you’re after.
The basic steps are …
json
expressionBasically, you need to parse the string value to an object and then evaluate it.