Open martijnsmitt opened 3 years ago
I have the same issue
Has someone found a solution for this problem?
Has someone found a solution for this problem?
unfortunately not. Have you found another npm package that solved your issue? Because I'm still looking for a good object to object mapping utility
{
"sourceObject": {
"key": "destObject",
transform: function (value,source,dest) {
if(Array.isArray(source.rootKey) && source.rootKey.length == 0) {
return [];
} else {
return [...dest.resultingArray];
}
},
default: []
}
}
It worked for me. but make sure you put it at the end of the key mapping
In response i was getting and
{ response: { data: { resultingArray: [] } } }
and what object mapper was doing
{ response: { data: { resultingArray: [ {} ] } } }
Hi! I'm using object-mapper for simplifying objects and came across a bug(?) or at least an unexpected result. When using the transform function the mapper wil always create a empty object. Check the example below
I expected that the result wouldn't return
shouldNotExist
, because there is notitle
, but insteadobject-mapper
returns an array with empty object. The example above is a minimal version of the real code, but isn't it possible to just return nothing and don't create an array if there is no data?