-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty object being created when mapping an empty array of objects #72
Comments
Has this worked for you in a previous version of object-mapper? |
Same issue. Did you find a workaround? I get empty objects. |
It work when there is no transform function, adding the transform function always create a dest = {} object, which is the one that end up being added to the array. |
It worked for me. but make sure you put it at the end of the key mapping |
Mapping an empty array (ex. empty result from db) to a mapping profile with a sub profile like this:
returns
[ {} ]
Adding "?" to the file does not fix this. As a workaround, I am checking the source length to decide whether or not to map.
Another issue I ran into is that a nulls do not work on a sub mapping if the source is null. For example, mapping this object which has a null "file" key, does not include the key in the result:
result:
I've tried "?" and default, resulting in the same issue:
The text was updated successfully, but these errors were encountered: