mapping array of objects
Closed this issue · 3 comments
patb23 commented
I want to transform an array , noticed that the output simply copies the source array and not honoring the transformation. Is it possible for me to achieve this with mapper?
const src = {
"foo": ["bar", "baz"],
"bar": [
{"key": "foo"},
{"key": "foo1"},
{"key": "foo2"},
{"key": "foo3"},
],
"baz": [["bar", null, "foo"]]
}
const map = {
"bar[]": {
"key": "destination[]+",
"transform": (val) => {
console.log(val) // transform not getting called
return "test"+val
}
},
"baz[]": {
"key": "destination[]+",
"transform": (val) => "test2"
}
}
// actual:
{"destination":[[{"key":"foo"},{"key":"foo1"},{"key":"foo2"},{"key":"foo3"}],[["bar",null,"foo"]]]}
//expected
{"destination":[[{"key":"testfoo"},{"key":"testfoo1"},{"key":"testfoo2"},{"key":"testfoo3"}],[["bar",null,"foo"]]]}
pguijarr commented
I have the same problem
g-bastianelli commented
I need this too please!!!!!!
wankdanker commented
This is available in object-mapper@6.1.0 on npm.
Thanks to all!