Forum Discussion
Hi @bojanvelevski similarly if i have two array called row and group as shown below
I need to replace the the value of second array ie group array with values from first array ie row array
to elaborate->row id in first array (row array) is corresponding to first record in second array(group array) and colid in first array(row array) is corresponding to A, B, C,D,E,F,G,H,I in the second array(group array).Example:first record of second array(group array) with values corresponding to column B and C must be updated with value ($) corresponding to first array(row array) with row id 1 and col id is 2 &col id is 3but remaining column values like A,D,E,F…I values should remain as incoming input values
Expected output is as shown below
Please could u help telling how can we achieve this using mapper expression here
If my understanding is correct, this is the same situation, isn’t it ?
You just need to tweak the expression a little bit.
- rashmi3 years agoNew Contributor III
Hi @bojanvelevski yes but here id corresponding to row comes in an array so how can we change it accordingly?
i tried this way its not working pls could u help if am missing something or doing wrong pls
input.json (1.0 KB)
@bojanvelevski, @alchemiz please could u help 😔- rashmi3 years agoNew Contributor III
Hi @bojanvelevski , @alchemiz if i try hardcoding the record 1 , record2 in the expression i am getting as expected but how can we dynamically loop across all record?
- alchemiz3 years agoContributor III
You’re trying to update the value from $row right?
$row.map(r=> r.mapValues((val,key)=> key == ‘col’ ? val.map(c=> c.mapValues((v,k)=> k == ‘$’ ? $group[r[‘@id’] - 1].values()[c[‘@id’] - 1] : v)) : val))