cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
raoraheel
Helper II
Helper II

Parsing JSON for an array variable

I need help please!

I'm trying to build this flow where im appending an array variable with some data and later need to retrieve that to build an html table off it. I'm having hard time setting the variable correctly and then parsing it. Below are my excerpts of steps from my flow where im setting the variable and retrieving them where I get this error. 

 

1. Initializing variable

Screen Shot 2021-09-16 at 8.45.49 AM.png

 

2. Appending data to variable

Screen Shot 2021-09-16 at 8.46.09 AM.png

 

3. Parsing the data from variable

 

Screen Shot 2021-09-16 at 8.46.22 AM.png

 

 

{

    "type""array",

    "items": {

        "type""object",

        "properties": {

            "ItemId": {

                "type""string"

            },

            "BatchId": {

                "type""string"

            },

            "DateTime": {

                "type""string"

            },

            "Qty": {

                "type""string"

            },

            "Location": {

                "type""string"

            }

        }

    }

}

 

4. Error I receive when i run my flow.

In this screenshot also see how my data is being stored in the variable

 

Screen Shot 2021-09-16 at 8.50.54 AM.png

 

Any suggestions to help me fix this and do it correctly will be highly appreciated. Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Can you send me a screenshot of the append to array action or the entire flow.

The data pasted above doesn't appear to be correct.  The Append to array action should resemble something like this, with no surrounding squares brackets [ ] :

ekarim2020_0-1631884469578.png

ekarim2020_1-1631885226152.png

Depending on what you are doing, you may not need to use Parse JSON. 

Ellis

View solution in original post

4 REPLIES 4
ekarim2020
Super User
Super User

Try modifying the Append to array action as:

ekarim2020_0-1631867905360.png

Example:

ekarim2020_2-1631868084320.png

 

Which results in an array

[
    {
        "Name""Apple",
        "Value""323"
    },
    {
        "Name""Mango",
        "Value""7731"
    }
]
 
Ellis

Ellis, when i do that and see the output in compose it looks like this

 

[
  "[\n{\n  \"Name\" : ItemId\"\n  \"Value\" : \"000875\"\n}\n{\n  \"Name\" : \"BatchId\"\n  \"Value\" : \"WO-025829SUB\"\n} \n {\n  \"Name\" : \"DateTime\"\n  \"Value\" :  \"2021-09-15T20:34:32Z\"\n}\n{\n  \"Name\" : \"Qty\"\n  \"Value\" : \"80\"\n{\n  \"Name\" : \"Location\"\n  \"Value\" : \"\"\n}]"
]
 
 
and when i use that to generate schema using sample I get this
 
{
    "type": "array",
    "items": {
        "type": "string"
    }
}
 
What am I still missing?
ekarim2020
Super User
Super User

Can you send me a screenshot of the append to array action or the entire flow.

The data pasted above doesn't appear to be correct.  The Append to array action should resemble something like this, with no surrounding squares brackets [ ] :

ekarim2020_0-1631884469578.png

ekarim2020_1-1631885226152.png

Depending on what you are doing, you may not need to use Parse JSON. 

Ellis

This visual helped alot! It was that square bracket and quotations. I'm all set now and was able to parse correctly to create my HTML table. Thanks so much for your help, Ellis!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,026)