Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jscarle/systemtextjsoncustomenumserialization

Comparing different methods of serializing and deserializing custom enum values using System.Text.Json in .NET.
https://github.com/jscarle/systemtextjsoncustomenumserialization

csharp deserialization dotnet enum json serialization system-text-json

Last synced: 25 days ago
JSON representation

Comparing different methods of serializing and deserializing custom enum values using System.Text.Json in .NET.

Awesome Lists containing this project

README

        

# System.Text.Json Custom Enum Serialization

Comparing different methods of serializing and deserializing custom enum values using [System.Text.Json](https://learn.microsoft.com/en-us/dotnet/api/system.text.json).

- Using the default `JsonSerializer` (see [source](https://github.com/jscarle/SystemTextJsonCustomEnumSerialization/blob/main/EnumSerialization.Tests/Default)📄).
- Using a reflection based `JsonConverter` (see [source](https://github.com/jscarle/SystemTextJsonCustomEnumSerialization/tree/main/EnumSerialization.Tests/Reflection)📄).
- Using an AOT compatible `JsonStringEnumConverter` with [source generation](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation)
as explained by [Eirik Tsarpalis](https://github.com/eiriktsarpalis) in this [comment](https://github.com/dotnet/runtime/issues/74385#issuecomment-1705083109) (see [source](https://github.com/jscarle/SystemTextJsonCustomEnumSerialization/tree/main/EnumSerialization.Tests/Aot)📄).

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/jscarle/SystemTextJsonCustomEnumSerialization/main.yml?logo=github&label=tests)