Skip to content
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

Mapping multiple fields to the same field in an object of an array #51

Open
shwetajoshi601 opened this issue Jun 11, 2018 · 1 comment

Comments

@shwetajoshi601
Copy link

Hi,
I am trying to map fields from different fields to fields of objects in an array into the destination object.
Following is my example:

{
    "firstName": "S",
    "lastName": "J",
    "Alias": [{
        "firstName": "S111",
        "lastName": "J111"
    }, {
        "firstName": "S111222",
        "lastName": "J1222211"
    }],
    "address": [
        {
            "streetName": "",
            "city": "S2"
        },
        {
            "streetName": "karve",
            "city": "pune"
        }
    ]
}

The mapping I do is as follows:

{
   "firstName": "Name[].FirstName",
    "lastName": "Name[].LastName",
    "Alias[].firstName": "Name[].FirstName",
    "Alias[].lastName": "Name[].LastName",
    "address[].streetName": "Address[].StreetName",
    "address[].city": "Address[].City"
}

As you can see, I want certain top level fields as well as fields from an array to be mapped to a single array. So, the expected object is:

{
    "Name": [
        {
            "FirstName": "S",
            "LastName": "J"
        },
        {
            "FirstName": "S111",
            "LastName": "J111"
        },
        {
            "FirstName": "S111222",
            "LastName": "J1222211"
        }
    ],
    "Address": [
        {
            "StreetName": "",
            "City": "S2"
        },
        {
            "StreetName": "karve",
            "City": "pune"
        }
    ]
}

However, the result is:

{
    "Name": [
        {
            "FirstName": "S111",
            "LastName": "J111"
        },
        {
            "FirstName": "S111222",
            "LastName": "J1222211"
        }
    ],
    "Address": [
        {
            "StreetName": "",
            "City": "S2"
        },
        {
            "StreetName": "karve",
            "City": "pune"
        }
    ]
}

The first value gets overwritten in the result. Is there any option to help retain all the values? Can this issue be fixed asap @wankdanker ?

@abhinav-juneja
Copy link

@shwetajoshi601 Were you able to find another way to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants