cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dilipvyas
New Member

Extract data from Json Array using MS Flow

Anyone have an idea how to  achieve below issue in  Flow

 

 

{
    "fields": [
        {
            "field": "field1",
            "type": "string"
        },
        {
            "field": "field2",
            "type": "string"
        },
        {
            "field": "field3",
            "type": "integer"
        },
        {
            "field": "eventTimestamp",
            "type": "date"
        }
    ],
    "results": [
        [
            "field1value1",
            "field2value1",
            10,
            "2018-05-31T22:55:31.187+0000"
        ],
        [
            "field1value2",
            "field2value2",
            20,
            "2018-05-31T22:55:31.187+0000"
        ],
        [
            "field1value3",
            "field2value3",
            30,
            "2018-05-31T22:55:31.187+0000"
        ]
    ]
}

 

My goal is to parse this data into dataset shaped like that with as the following table:

field1          field2          field3      eventTimestamp
field1value1    field2value1    10          2018-05-31T22:55:31.187+0000
field1value2    field2value2    20          2018-05-31T22:55:31.187+0000
field1value3    field2value3    30          2018-05-31T22:55:31.187+0000
1 ACCEPTED SOLUTION

Accepted Solutions
v-zhos-msft
Solution Sage
Solution Sage

Hi @dilipvyas ,

I have made a flow for your scenario, please check it for a reference:

The value in the 'Compose' is the Json you provided.

The expression 'Compose 2' to 'Compose5' are:

outputs('Compose')?['fields']
outputs('Compose')?['results']
length(outputs('Compose_2'))
length(outputs('Compose_3'))
The output in 'Do Until 2' is Compose 4.
The expression in 'Append to array variable 2' is:
outputs('Compose_2')?[variables('length')]?['field']
The output in 'Do Until' is Compose 5.
The expression in 'Append to array variable' are:
{
"outputs('Compose_6')?[0]" : outputs('Compose_3')?[variables('index')]?[0],
"outputs('Compose_6')?[1]" : outputs('Compose_3')?[variables('index')]?[1],
"outputs('Compose_6')?[2]" : outputs('Compose_3')?[variables('index')]?[2],
"outputs('Compose_6')?[3]" : outputs('Compose_3')?[variables('index')]?[3]
}
 

 

Capture3.PNGCapture4.PNGCapture5.PNGCapture6.PNGCapture7.PNG

Capture8.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-zhos-msft
Solution Sage
Solution Sage

Hi @dilipvyas ,

I have made a flow for your scenario, please check it for a reference:

The value in the 'Compose' is the Json you provided.

The expression 'Compose 2' to 'Compose5' are:

outputs('Compose')?['fields']
outputs('Compose')?['results']
length(outputs('Compose_2'))
length(outputs('Compose_3'))
The output in 'Do Until 2' is Compose 4.
The expression in 'Append to array variable 2' is:
outputs('Compose_2')?[variables('length')]?['field']
The output in 'Do Until' is Compose 5.
The expression in 'Append to array variable' are:
{
"outputs('Compose_6')?[0]" : outputs('Compose_3')?[variables('index')]?[0],
"outputs('Compose_6')?[1]" : outputs('Compose_3')?[variables('index')]?[1],
"outputs('Compose_6')?[2]" : outputs('Compose_3')?[variables('index')]?[2],
"outputs('Compose_6')?[3]" : outputs('Compose_3')?[variables('index')]?[3]
}
 

 

Capture3.PNGCapture4.PNGCapture5.PNGCapture6.PNGCapture7.PNG

Capture8.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,947)