Replace values with a value in another value

Hi all,

I have an object containing the following data:

"EF000003":{
 "Value":"EV010173"
 "Datatype":"picklist"
 "InternationalCharacteristicCode":"EF000003"
 "Description":"Montagewijze"
 "orderNumber":5
 "Unit":""
 "newValue":{
  "EV000028":"Universeel"
  "EV008457":"Op kabelgoot"
  "EV010173":"Wand-/plafondmontage"
  "EV011419":"op het centrale vak"
 }
}

I need to replace the string in Value with the actual value that corresponds in newValue. In this example, this should be the outcome:

"EF000003":{
 "Value":"Wand-/plafondmontage"
 "Datatype":"picklist"
 "InternationalCharacteristicCode":"EF000003"
 "Description":"Montagewijze"
 "orderNumber":5
 "Unit":""
}

Any easy way to achieve this?

Hey @j.wiegmann
The simplest way this could be done is to intersect it by that value(EV010173), since its the only common ground with objects inside the “newValue”.
Make a new key value pair, so you can use the Operator, Array Intersect keys, even if you have two objects to compare, it will still work.
something like:


  "setPathToTake": {
    "EV010173": "EV010173"
  }
}

When intersecting it will only get the object with the same key and all the data, the expected result is the example you provided.


See transformer for full example.
export_20240513220924.ndjson (1.4 KB)

1 Like

Thank you very much. I had not used the Array Intersect option yet!