-
I am trying to figure out how to handle the need of flattening the id properties in child objects. Now my response look like this: {
"id": "1cec7335-437d-4254-aa6e-4feaa2513f72",
"createdDate": "2024-05-13T07:04:04.1633826",
"valueObjectOne": "Test One",
"valueObjectTwo": "Test One",
"childEntityOne": {
"id": "ChildEntityOneId { Value = f7a4f8cc-5ede-4066-8bc3-24669d803223 }",
"createdDate": "2024-05-13T07:04:04.1626767",
"valueObjectTwo": "Test One",
"childEntityTwos": [
{
"id": "ChildEntityTwoId { Value = f803f7b7-57d8-4f89-9912-a392a4f1a46e }",
"createdDate": "2024-05-13T07:04:04.1625806",
"valueObjectTwo": "Test One"
},
{
"id": "ChildEntityTwoId { Value = ac7e77eb-e1b6-42d5-80a0-f97248fa5e87 }",
"createdDate": "2024-05-13T07:04:04.1621517",
"valueObjectTwo": "Test One"
}
]
}
} Flattening the id for the top level parrent works just fine like this: But how do I get to the id of the nested ChildEntityOne and to each ChildEntityTwo's? Can't seem to find anything about that in the documentation. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Can at least someone confirm that I am alive and exist? :-) |
Beta Was this translation helpful? Give feedback.
-
Thank you for using Mapperly and starting this discussion. Please remember that this is a free open source project that we maintain in on a best efforts basis. I have fixed the formatting of your post (you can use markdown and thus triple backticks to format blocks of code, see GH markdown). It appears to be a JSON representation of an actual C# object tree, is it? Some values appear to be string serialised and not structured as JSON, for example |
Beta Was this translation helpful? Give feedback.
Actually, I just figured out that I can use custom mapping like this:
// Custom mapping
private AggregateOneId MapToAggregateOneId(string id) => new AggregateOneId(Guid.Parse(id));
private string MapToAggregateOneIdString(AggregateOneId id) => id.Value.ToString();
private string MapToChildEntityOneIdString(ChildEntityOneId id) => id.Value.ToString();
private string MapToChildEntityTwoIdString(ChildEntityTwoId id) => id.Value.ToString();