Set of System.Text.Json Converts that are not included by default.
Support for converting Json to Mixed Dtos and directly to dynamics using ExpandoObjects is lacking in System.Text.Json. The Fermin.Text.Json.Converters.DynamicConverter fills that gap.
e.g.
Mixed Dto
public class MixedDto
{
public string foo {get; set;}
public dynamic bar {get; set;}
}
// add converter to serializer using extension method
var options = new JsonSerializerOptions().AddDynamicConverter();
// convert to dto
MixedDto dto = JsonSerializer.Deserialize<MixedDto>(json, options);
Directly to dynamic
// add converter to serializer using extension method
var options = new JsonSerializerOptions().AddDynamicConverter();
dynamic dto = JsonSerializer.Deserialize<dynamic>(json, options);
Annotated Dto
public class AnnotatedMixedDto
{
public string foo {get; set;}
[JsonConverter(typeof(DynamicConverter))]
public dynamic bar {get; set;}
}