Search code examples
azure-logic-apps

JSON properties in to an array (are all jobs complete)


The JSON below comes from an entity on table storage. There will be more "item" properties added and removed over time - they represent whether a job has completed or not. My goal is to understand when all jobs have completed.

In a Logic App I check if any items are false. I won't know the name of the "item" in advance.

I'm looking for a method to map the JSON properties in to an array. Is there such a method or is there another way?

{
"odata.etag": "W/"datetime'2024-02-22T14%3A28%3A16.3091774Z'"",
"PartitionKey": "2024",
"RowKey": "08584929947924424952570595495CU00",
"Timestamp": "2024-02-22T14:28:16.3091774+00:00",
"item-001": "false", "item-002": "false", }


Solution

  • You could run a JavaScript code snippet in your workflow, e.g.

    let obj = workflowContext.actions.Compose.outputs;
    let arr = Object.keys(obj).map(key => ({name: key, value: obj[key]}));
    return arr;
    

    This is what it would look like: enter image description here

    enter image description here

    enter image description here