wankdanker / node-object-mapper

Copy properties from one object to another.
MIT License
277 stars 73 forks source link

null value check not iterating correctly in arrays #80

Open dreaganluna opened 4 years ago

dreaganluna commented 4 years ago

In any version >5.0.0, the question mark that is used for null values does not iterate correctly in arrays. By that I mean that this will only work for the first item in an array.

Mapping example:

const mapping = {
    "source[].some": "destination[].some",
    "source[].empty": "destination[].empty?"
};

Result in 5.0.0 or less:

{
    "destination": [
        {
            "some": "value",
            "empty": null
        },
        {
            "some": "value",
            "empty": null
        },
        {
            "some": "value",
            "empty": null
        }
    ]
}

Result in >5.0.0:

{
    "destination": [
        {
            "some": "value",
            "empty": null
        },
        {
            "some": "value"
        },
        {
            "some": "value"
        }
    ]
}