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

Submapping or mapping with in a map #94

Open
tmorford opened this issue Sep 8, 2022 · 0 comments
Open

Submapping or mapping with in a map #94

tmorford opened this issue Sep 8, 2022 · 0 comments

Comments

@tmorford
Copy link

tmorford commented Sep 8, 2022

I have an object:

const srcA = [{ "person": { "firstName": "John", "middleName": "Michael", "lastName": "Doe" }, "contact": { "phones": [{ "type": "cell", "number": "999-888-7777" }, { "type": "home", "number": "666-555-4444" }, { "type": "work", "number": "333-222-1111", "extension": "123" } ], "emailAddresses": [{ "type": "personal", "email": "[email protected]" }, { "type": "work", "email": "[email protected]" } ], "addresses": [{ "type": "home", "lineOne": "987 Home St.", "lineTwo": "Apt G", "city": "Hometown", "state": "CO", "zip": "80027", "country": "USA" }, { "type": "work", "lineOne": "654 Work Rd.", "lineTwo": "Suite 205", "city": "Workcity", "state": "CO", "zip": "80026", "country": "USA" } ] } }, { "person": { "firstName": "Anthony", "middleName": "Scott", "lastName": "Doe", "birthDate": "1991/02/29" }, "contact": { "phones": [{ "type": "cell", "number": "666-222-4444" }], "emailAddresses": [{ "type": "personal", "email": "[email protected]" }], "addresses": [{ "type": "home", "lineOne": "3456 Living St.", "city": "Hometown", "state": "CO", "zip": "80027", "country": "USA" }] } } ]

I am trying to map:
const mapA = { "[].person.firstName":"[].firstName", "[].person.middleName":"[].middleName", "[].person.lastName":"[].lastName", "[].person.birthDate":"[].birthDate", "[].contact.phones[]":"[]communication[]", "[].contact.emailAddresses[]":"[]communication[]", "[].contact.addresses[]":"[]communication[]" }

In automapper c# version I could map and then have a submap of part of the object to map also.
What I am trying to do is map "[].contact.phones[]":"[]communication[]", "[].contact.emailAddresses[]":"[]communication[]","[].contact.addresses[]":"[]communication[]"
but your system just kind of makes the phone, email and address all one node, and removes parts of the data. I would like to do somerthing like []communication[] : [{[].contact.phones[],[].contact.emailAddresses[],[].contact.addresses[] }] to give this results:
"communication": [{
"communicationMethod": "Address",
"communicationType": "Home",
"addressLineOne": "1234 Rocky Road",
"addressLineTwo": "Apt 7",
"addressCity": "Blanket",
"addressState": "CO",
"addressZip": "80029",
"addressCountry": "USA"
}, {
"communicationMethod": "EmailAddress",
"communicationType": "Personal",
"emailAddress": "[email protected]"
}, {
"communicationMethod": "Phone",
"communicationType": "Work",
"phoneNumber": "789-123-4444",
"phoneExtension": "978"
}

not this:
[[{
"type": "home",
"lineOne": "987 Home St.",
"lineTwo": "Apt G",
"city": "Hometown",
"state": "CO",
"zip": "80027",
"country": "USA"
}, {
"type": "work",
"lineOne": "654 Work Rd.",
"lineTwo": "Suite 205",
"city": "Workcity",
"state": "CO",
"zip": "80026",
"country": "USA"
}
], [{
"type": "home",
"lineOne": "3456 Living St.",
"city": "Hometown",
"state": "CO",
"zip": "80027",
"country": "USA"
}
]]
app.zip

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

1 participant