cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dignus93reply
Frequent Visitor

Merging two JSON arrays of the same size

Hello folks I have two json array of the same size. 

 

 

 

ARRAY1:

[
{
"Column1": "Main directory1",
"Column2": "Sub directory1"
},

{
"Column1": "Main directory2",
"Column2": "Sub directory2"
},

{
"Column1": "Main directory3",
"Column2": "Sub directory3"
}
]

 

 

 

ARRAY2:

[
{
"Column3": "urlNum1"
},

{
"Column3":"UrlNum2"
},

{
"Column3":"UrlNum3"
}
]

 

 

 

I would like to have output like this:

[
{
"Column1": "Main directory1",
"Column2": "Sub directory1",
"Column3": "urlNum1"
},

{
"Column1": "Main directory2",
"Column2": "Sub directory2",
"Column3":"UrlNum2"
},

{
"Column1": "Main directory3",
"Column2": "Sub directory3",
"Column3":"UrlNum3"
}
]

 

 

 

I am trying with Apply to each or Do Until or Append to variable but I am struggling a lot. Can you help me?

1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Super User II
Super User II

Hi @dignus93reply ,

Here is my thoughts. To save some space please follow the number:

a) Let's initialize some stuff:

1.gabibalaban_0-1616522499731.png

 

2.gabibalaban_1-1616522536007.png

 

3.gabibalaban_2-1616522635473.png

 

4.gabibalaban_3-1616522654212.png

 

b) And now, here is the magic 😊 ... 

gabibalaban_4-1616522806556.png

Hope it helps !

View solution in original post

2 REPLIES 2
gabibalaban
Super User II
Super User II

Hi @dignus93reply ,

Here is my thoughts. To save some space please follow the number:

a) Let's initialize some stuff:

1.gabibalaban_0-1616522499731.png

 

2.gabibalaban_1-1616522536007.png

 

3.gabibalaban_2-1616522635473.png

 

4.gabibalaban_3-1616522654212.png

 

b) And now, here is the magic 😊 ... 

gabibalaban_4-1616522806556.png

Hope it helps !

View solution in original post

dignus93reply
Frequent Visitor

Thanks a lot @gabibalaban this works good in this case.

 

Now let's level up. What if I have the same ARRAY1 as before
ARRAY1:
[
{
"Column1": "Main directory1",
"Column2": "Sub directory1"
},

{
"Column1": "Main directory2",
"Column2": "Sub directory2"
},

{
"Column1": "Main directory3",
"Column2": "Sub directory3"
}
]

 

but the ARRAY2 now has more key-values for each record. The length it's still the same of the other
ARRAY2:
[
{
"Column3": "urlNum1",
"Column4": "prop1",
"Column5": "asd1"
},

{
"Column3":"UrlNum2",
"Column4": "prop2",
"Column5": "asd2"
},

{
"Column3":"UrlNum3",
"Column4": "prop3",
"Column5": "asd3"
}
]


my desired output follow the same patter as before
ARRAYOUTPUT:
[
{
"Column1": "Main directory1",
"Column2": "Sub directory1",
"Column3": "urlNum1",
"Column4": "prop1",
"Column5": "asd1"
},

{
"Column1": "Main directory2",
"Column2": "Sub directory2"
"Column3":"UrlNum2",
"Column4": "prop2",
"Column5": "asd2"
},

{
"Column1": "Main directory3",
"Column2": "Sub directory3",
"Column3":"UrlNum3",
"Column4": "prop3",
"Column5": "asd3"
}
]

 

I guess I can follow your pattern and do this reading the key value manually. But is there a way to loop through ARRAY1 and ARRAY2 in order to have a ARRAYOUTPUT???

Regards,
Alessandro

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (61,368)