Skip to content

Set of System.Text.Json Converts that are not included by default.

License

Notifications You must be signed in to change notification settings

jorelius/Fermin.Text.Json.Converters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fermin.Text.Json.Converters

Set of System.Text.Json Converts that are not included by default.

Install

Nuget

Converters

Dynamic

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;}
}

About

Set of System.Text.Json Converts that are not included by default.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages