0

How can I parse the below JSON in power automate to get the value of multi choice column 'MyChoice'.

I am trying to parse it using expression body('Parse_JSON_2')?['d']?['result']?[1]?['MyChoice']?['results'] but its not working.

Any help is appreciated.

Here is the sample JSON:

{
    "body": {
        "d": {
            "results": [
                {
                    "__metadata": {
                        "id": "",
                        "uri": "",
                        "type": ""
                    },
                    "CreatedBy": {
                        "__deferred": {
                            ""
                        }
                    },
                    "Fields": {
                        "__deferred": {
                            "uri": ""
                        }
                    },
                    "FileVersion": {
                        "__deferred": {
                            "uri": ""
                        }
                    },
                    "Created": "",
                    "**MyChoice**": {
                        "__metadata": {
                            "type": "Collection(Edm.String)"
                        },
                        "results": [
                            "choice1",
                             "choice2"
                        ]
                    },
                    ]
}
}
                }
0

Not sure how your schema was generated. Tested with a Multi-Select choice column of a SPO list with the schema shown below (Note that schema has been manually modified from the output of [Get items])

In Power Automate, Multi-Select Choice column values are returned as an array, so need to treat them as an array as well.

SPO List enter image description here

Schema

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "@@odata.etag": {
                "type": "string"
            },
            "ItemInternalId": {
                "type": "string"
            },
            "ID": {
                "type": "integer"
            },
            "MyChoiceFruits": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "@@odata.type": {
                            "type": "string"
                        },
                        "Id": {
                            "type": "integer"
                        },
                        "Value": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@@odata.type",
                        "Id",
                        "Value"
                    ]
                }
            }
        },

        "required": [
                        "@@odata.etag",
                        "ItemInternalId",
                        "ID",
                        "MyChoiceFruits"
                    ]

    }
}

#Get first item's choice field values as an array

body('Parse_JSON')?[0]?['MyChoiceFruits']

#Get first item's first choice field's value. 

body('Parse_JSON')?[0]?['MyChoiceFruits']?[0]['Value']

output

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.