Forum Discussion

JensDeveloper's avatar
JensDeveloper
Contributor II
3 years ago
Solved

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

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

  • Hi @JensDeveloper,

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

    Expression used:

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

    Let me know if this helps.

    BR,
    Aleksandar.

1 Reply

  • Hi @JensDeveloper,

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

    Expression used:

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

    Let me know if this helps.

    BR,
    Aleksandar.