Class JsonAttributes
- Namespace
- TypedRest.CodeGeneration.CSharp
- Assembly
- TypedRest.CodeGeneration.CSharp.dll
Supplies the attributes that carry wire names on generated DTOs, for one specific JSON serializer.
public abstract class JsonAttributes
- Inheritance
-
objectJsonAttributes
- Derived
Remarks
TypedRest for .NET serializes with Newtonsoft.Json out of the box; System.Text.Json is available through the
TypedRest.SystemTextJson package. The two read entirely different attributes, so a DTO annotated for one
silently falls back to its C# member names under the other.
Fields
Newtonsoft
Newtonsoft.Json, used by the TypedRest package by default.
public const string Newtonsoft = "newtonsoft"
Field Value
SystemTextJson
System.Text.Json, used through the TypedRest.SystemTextJson package.
public const string SystemTextJson = "system-text-json"
Field Value
Properties
Names
The serializer names For(string?) accepts, most preferred first.
public static IReadOnlyCollection<string> Names { get; }
Property Value
Serializer
The name of the serializer these attributes are for.
public abstract string Serializer { get; }
Property Value
Methods
EnumMemberName(string)
Carries the wire name of an enum value whose C# name differs from it.
public abstract CSharpAttribute EnumMemberName(string name)
Parameters
namestring
Returns
For(string?)
Returns the attributes for name, or the default serializer if it is null.
public static JsonAttributes For(string? name)
Parameters
namestring
Returns
Exceptions
- ArgumentException
nameis not one of Names.
PropertyName(string)
Carries the wire name of a property whose C# name differs from it.
public abstract CSharpAttribute PropertyName(string name)
Parameters
namestring