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

Change array to object and extract certain characters from it

JensDeveloper
Contributor II

Hi,

I am trying to change the array to an object and after that only get the value between the ()

Example:
Input
[
{
โ€œSystemsโ€ : [โ€œArdoq (431)โ€, โ€œSnapLogic (780)โ€]
}
{
โ€œSystemsโ€ : [โ€œSnapLogic (780)โ€]
}
]

Expected output:
[
{
โ€œSystemsโ€ : โ€œ431โ€,
โ€œSystemsโ€ : โ€œ780โ€
}
{
โ€œSystemsโ€ : โ€œ780โ€
}
]
Pipeline is below with the transformation I already tried with toObjectโ€ฆ
get_valuesFromArray_2022_07_11.slp (6.2 KB)
And I tried also this replace transformation from my last topic: Map expression regex - #6 by JensDeveloper and then change it to โ€˜(โ€™ to extract the character afther the โ€˜(โ€™

Regards

Jens

1 ACCEPTED SOLUTION

nsingam
Employee
Employee

Hi,

Use the below expression in a mapper. After that use the Splitter snap to get the details.

$Systems.map(x => {โ€œSystemsโ€ : x.substring(x.indexOf(โ€œ(โ€)+1, x.indexOf(โ€œ)โ€))})

View solution in original post

2 REPLIES 2

nsingam
Employee
Employee

Hi,

Use the below expression in a mapper. After that use the Splitter snap to get the details.

$Systems.map(x => {โ€œSystemsโ€ : x.substring(x.indexOf(โ€œ(โ€)+1, x.indexOf(โ€œ)โ€))})

Hey @nsingam ,

Thank you for your answer. It works.