Unable to map class if property has JsonDocument class
NanFengCheong opened this issue · 3 comments
NanFengCheong commented
SteveWilkes commented
SteveWilkes commented
Actually, sorry - I think it's just a configuration issue.
Instead of:
Mapper.WhenMapping
.From<JsonDocument>()
.ToANew<JsonDocument>()
.CreateInstancesUsing(ctx => JsonDocument.Parse(ctx.Source.RootElement.GetRawText(), default));
Use:
Mapper.WhenMapping
.From<JsonDocument>()
.To<JsonDocument>()
.CreateInstancesUsing(ctx => JsonDocument.Parse(ctx.Source.RootElement.GetRawText(), default));
Using ToANew<T>()
applies the configuration only to new object mappings, not to updates as you're doing in your fiddle.
Hope that helps,
Steve
NanFengCheong commented
Seems working now. Thanks