cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Get each value from an array and create for each a record

JensDeveloper
Contributor II

HI experts,

I have this input and the array of EmailAdresses can consist of 1 - 5 addresses:
[
{
โ€œBusinessPartnerโ€:โ€œ10โ€,
โ€œLastNameโ€:โ€œlamโ€,
โ€œSearchTerm1โ€:โ€œlamโ€,
โ€œto_BusinessPartnerAddressโ€:{
โ€œresultsโ€:[
{
โ€œBusinessPartnerโ€:โ€œ10โ€,
โ€œCountryโ€:โ€œDEโ€,
โ€œto_EmailAddressโ€:{
โ€œresultsโ€:[
{
โ€œEmailAddressโ€:[
โ€œinfo@gmail.comโ€,
โ€œtest@gmail.comโ€
]
}
]
}
}
]
}
}
]

I want to accomplish this (get all the values from the array and put them below each other as strings):
[
{
โ€œBusinessPartnerโ€: โ€œ10โ€,
โ€œLastNameโ€: โ€œtestlastnameโ€,
โ€œSearchTerm1โ€: โ€œlamโ€,
โ€œto_BusinessPartnerAddressโ€: {
โ€œresultsโ€: [
{
โ€œBusinessPartnerโ€: โ€œ10โ€,
โ€œCountryโ€: โ€œDEโ€,
โ€œto_EmailAddressโ€: {
โ€œresultsโ€: [
{
โ€œEmailAddressโ€: โ€œinfo@gmail.comโ€
},
{
โ€œEmailAddressโ€: โ€œtest@gmail.comโ€
}
]
}
}
]
}
}
]

How can I accompllish this I already tried to change it to an object, but I think itโ€™s something with mapping.

Regards

Jens

1 ACCEPTED SOLUTION

AleksandarAngel
Contributor III

Hi @JensDeveloper,

You can try by using Mapper Snap with the following settings:
image

Expression used:

jsonPath($, "$EmailAddress[*]").map(x => {"EmailAddress":x})

Let me know if this helps.

BR,
Aleksandar.

View solution in original post

1 REPLY 1

AleksandarAngel
Contributor III

Hi @JensDeveloper,

You can try by using Mapper Snap with the following settings:
image

Expression used:

jsonPath($, "$EmailAddress[*]").map(x => {"EmailAddress":x})

Let me know if this helps.

BR,
Aleksandar.