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.