system_text_json_enumextensions - EnumExtensions.System.Text.Json 1.2.0-ci-110208
Extensions to the JsonStringEnumConverter which supports attributes like EnumMember, Display and Description.
PM> Install-Package EnumExtensions.System.Text.Json -Version 1.2.0-ci-110208 -Source https://www.myget.org/F/system_text_json_enumextensions/api/v3/index.json
> nuget.exe install EnumExtensions.System.Text.Json -Version 1.2.0-ci-110208 -Source https://www.myget.org/F/system_text_json_enumextensions/api/v3/index.json
> dotnet add package EnumExtensions.System.Text.Json --version 1.2.0-ci-110208 --source https://www.myget.org/F/system_text_json_enumextensions/api/v3/index.json
<PackageReference Include="EnumExtensions.System.Text.Json" Version="1.2.0-ci-110208" />
Copy to clipboard
source https://www.myget.org/F/system_text_json_enumextensions/api/v3/index.json
nuget EnumExtensions.System.Text.Json ~> 1.2.0-ci-110208
Copy to clipboard
> choco install EnumExtensions.System.Text.Json --version 1.2.0-ci-110208 --source https://www.myget.org/F/system_text_json_enumextensions/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "system_text_json_enumextensions" -SourceLocation "https://www.myget.org/F/system_text_json_enumextensions/api/v2"
Install-Module -Name "EnumExtensions.System.Text.Json" -RequiredVersion "1.2.0-ci-110208" -Repository "system_text_json_enumextensions" -AllowPreRelease
Copy to clipboard
System.Text.Json.Extensions
Some extensions to the JsonStringEnumConverter which supports attributes like EnumMember, Display and Description
Info
| Build Azure | |
| NuGet | |
| MyGet (preview) |
Installing
You can install from NuGet using the following command in the package manager window:
Install-Package EnumExtensions.System.Text.Json
Or via the Visual Studio NuGet package manager.
If you use the dotnet command:
dotnet add package EnumExtensions.System.Text.Json
Option 1: Usage Example - EnumMember
Define Enum and add attributes
Define an Enum and annotate the Enum fields with the EnumMemberAttribute:
enum WeatherType
{
[EnumMember(Value = "Zonnig")]
Sunny,
[EnumMember(Value = "Helder")]
Clear
}
Add Converter
Add the new JsonStringEnumConverterWithAttributeSupport to the Converters via the JsonSerializerOptions:
var options = new JsonSerializerOptions();
options.Converters.Add(new JsonStringEnumConverterWithAttributeSupport());
Serialize an object
var weatherForecast = new WeatherForecast
{
WeatherType = WeatherType.Sunny
};
var weatherForecastSerialized = JsonSerializer.Serialize(weatherForecast, options);
Console.WriteLine(weatherForecastSerialized); // {"WeatherType":"Zonnig"}
Deserialize an object
Deserialize works by using the same options:
var json = "{\"WeatherType\":\"Zonnig\"}";
var weatherForecastDeserialized = JsonSerializer.Deserialize<WeatherForecast>(json, options);
Option 2: Usage Example - EnumMember
It's also possible to annotate the Enum with a [JsonConverter] so that you don't need to manually registerd the JsonStringEnumConverterWithAttributeSupport to the Converters via the JsonSerializerOptions.
Define Enum and add attributes
Define an Enum
- add the
[JsonConverter(typeof(JsonStringEnumConverterWithAttributeSupport))]to the Enum - annotate the Enum fields with the EnumMemberAttribute:
[JsonConverter(typeof(JsonStringEnumConverterWithAttributeSupport))]
enum WeatherType
{
[EnumMember(Value = "Zonnig")]
Sunny,
[EnumMember(Value = "Helder")]
Clear
}
Generic Attribute is also supported:
[JsonConverter(typeof(JsonStringEnumConverterWithAttributeSupport<WeatherType>))]
enum WeatherType
{
[EnumMember(Value = "Zonnig")]
Sunny,
[EnumMember(Value = "Helder")]
Clear
}
Serializing and Deserialize an object
This works the same as using Option 1.
Note that only Enum values which are annotated with EnumMember are supported.
Usage Example - Display and Description
It's also possible to annotate Enum fields with these attributes:
Define Enum and add attributes
enum WeatherType
{
[EnumMember(Value = "Zonnig")]
Sunny,
[Display(Name = "Helder")]
Clear,
[Description("Bewolkt")]
Cloudy
}
Add Converter
! By default, the Display and Description are disabled, use the following line to enable these.
var options = new JsonSerializerOptions();
options.Converters.Add(new JsonStringEnumConverterWithAttributeSupport(null, true, true, true, true));
Serializing and Deserializing works the same.
Sponsors
Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of System.Text.Json.Extensions.
See CHANGELOG.md
-
.NETFramework 5.0
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 4.6.0)
-
.NETStandard 2.1
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 8.0.4)
- .NETFramework 5.0: 5.0.0.0
- .NETStandard 2.0: 2.0.0.0
- .NETStandard 2.1: 2.1.0.0
OwnersStef |
AuthorsStef Heyenrath |
Project URLhttps://github.com/StefH/System.Text.Json.EnumExtensions |
LicenseUnknown |
TagsSystem Text Json Enum EnumMember EnumMemberAttribute Attribute DisplayAttribute DescriptionAttribute |
Info2231 total downloads |
| 84 downloads for version 1.2.0-ci-110208 |
| Download (16.5 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
1.3.0-ci-110569 | 20.07 KB | Mon, 13 Oct 2025 05:45:37 GMT | 22 |
|
||
|
|
1.2.1-ci-110568 | 20.08 KB | Mon, 13 Oct 2025 05:43:13 GMT | 36 |
|
||
|
|
1.2.1-ci-110567 | 20.05 KB | Mon, 13 Oct 2025 05:43:02 GMT | 34 |
|
||
|
|
1.2.1-ci-110566 | 20.06 KB | Sun, 12 Oct 2025 14:53:52 GMT | 35 |
|
||
|
|
1.2.1-ci-110216 | 17.74 KB | Wed, 18 Jun 2025 11:48:59 GMT | 86 |
|
||
|
|
1.2.0-ci-18909 | 16.44 KB | Tue, 09 Jul 2024 21:24:19 GMT | 72 |
|
||
|
|
1.2.0-ci-18553 | 16.45 KB | Fri, 17 May 2024 15:44:25 GMT | 79 |
|
||
|
|
1.2.0-ci-110215 | 17.75 KB | Wed, 18 Jun 2025 11:47:39 GMT | 82 |
|
||
|
|
1.2.0-ci-110214 | 17.76 KB | Wed, 18 Jun 2025 11:45:24 GMT | 84 |
|
||
|
|
1.2.0-ci-110213 | 17.74 KB | Wed, 18 Jun 2025 11:41:28 GMT | 71 |
|
||
|
|
1.2.0-ci-110212 | 17.75 KB | Wed, 18 Jun 2025 11:40:20 GMT | 98 |
|
||
|
|
1.2.0-ci-110211 | 17.73 KB | Wed, 18 Jun 2025 11:38:25 GMT | 86 |
|
||
|
|
1.2.0-ci-110210 | 16.49 KB | Wed, 18 Jun 2025 11:35:38 GMT | 88 |
|
||
|
|
1.2.0-ci-110209 | 16.5 KB | Wed, 18 Jun 2025 11:33:37 GMT | 74 |
|
||
|
|
1.2.0-ci-110208 | 16.5 KB | Wed, 18 Jun 2025 11:31:59 GMT | 84 |
|
||
|
|
1.1.0-ci-18552 | 16.42 KB | Fri, 17 May 2024 15:41:50 GMT | 72 |
|
||
|
|
1.1.0-ci-18546 | 16.44 KB | Fri, 17 May 2024 08:17:17 GMT | 64 |
|
||
|
|
1.1.0-ci-18544 | 16.43 KB | Fri, 17 May 2024 07:47:46 GMT | 84 |
|
||
|
|
1.1.0-ci-18543 | 16.45 KB | Thu, 16 May 2024 09:50:38 GMT | 82 |
|
||
|
|
1.1.0-ci-18542 | 16.44 KB | Thu, 16 May 2024 07:45:54 GMT | 74 |
|
||
|
|
1.1.0-ci-16545 | 16.1 KB | Sun, 16 Oct 2022 07:49:06 GMT | 83 |
|
||
|
|
1.1.0-ci-15739 | 16.1 KB | Mon, 03 Jan 2022 11:32:38 GMT | 59 |
|
||
|
|
1.0.1-ci-14819 | 16.07 KB | Sat, 20 Mar 2021 08:50:37 GMT | 58 |
|
||
|
|
1.0.1-ci-14818 | 16.08 KB | Sat, 20 Mar 2021 08:46:31 GMT | 75 |
|
||
|
|
1.0.1-ci-14816 | 16.08 KB | Sat, 20 Mar 2021 08:44:27 GMT | 78 |
|
||
|
|
1.0.0-preview-01-ci-12025 | 6.82 KB | Sun, 13 Oct 2019 09:26:24 GMT | 80 |
|
||
|
|
1.0.0-ci-14790 | 6.8 KB | Fri, 12 Mar 2021 16:19:01 GMT | 73 |
|
||
|
|
1.0.0-ci-13722 | 6.74 KB | Sun, 30 Aug 2020 10:21:36 GMT | 89 |
|
||
|
|
1.0.0-ci-12163 | 6.74 KB | Fri, 08 Nov 2019 06:39:00 GMT | 81 |
|
||
|
|
1.0.0-ci-12162 | 6.74 KB | Fri, 08 Nov 2019 06:38:27 GMT | 75 |
|
||
|
|
1.0.0-ci-12026 | 6.74 KB | Sun, 13 Oct 2019 09:53:09 GMT | 73 |
|

