forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for overriding enum field name in JsonConverterEnum (dotnet#3…
- Loading branch information
Showing
5 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
....Text.Json/src/System/Text/Json/Serialization/Attributes/JsonStringEnumMemberAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Text.Json.Serialization | ||
{ | ||
/// <summary> | ||
/// Specifies the enum member that is present in the JSON when serializing and deserializing. | ||
/// This overrides any naming policy specified by <see cref="JsonNamingPolicy"/>. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] | ||
public sealed class JsonStringEnumMemberAttribute : JsonAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of <see cref="JsonStringEnumMemberAttribute"/> with the specified enum member name. | ||
/// </summary> | ||
/// <param name="name">The name of the enum member.</param> | ||
public JsonStringEnumMemberAttribute(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
/// <summary> | ||
/// The name of the enum member. | ||
/// </summary> | ||
public string Name { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters