Class JsonSerializerOptionsExtensions
- Namespace
- Cuemon.Extensions.Text.Json
- Assembly
- Cuemon.Extensions.Text.Json.dll
Extension methods for the JsonSerializerOptions class.
public static class JsonSerializerOptionsExtensions
- Inheritance
-
JsonSerializerOptionsExtensions
Methods
Clone(JsonSerializerOptions, Action<JsonSerializerOptions>)
Copies the options from a JsonSerializerOptions instance to a new instance.
public static JsonSerializerOptions Clone(this JsonSerializerOptions options, Action<JsonSerializerOptions> setup = null)
Parameters
options
JsonSerializerOptionsThe JsonSerializerOptions to extend.
setup
Action<JsonSerializerOptions>The JsonSerializerOptions which may be configured.
Returns
- JsonSerializerOptions
A new cloned instance of
options
with optional altering as specified by thesetup
delegate.
Exceptions
- ArgumentNullException
options
cannot be null.
SetPropertyName(JsonSerializerOptions, String)
Returns the specified name
adhering to the underlying PropertyNamingPolicy.
public static string SetPropertyName(this JsonSerializerOptions options, string name)
Parameters
options
JsonSerializerOptionsThe options from which to apply a property naming policy.
name
StringThe name to apply to a JSON property.
Returns
- String
When PropertyNamingPolicy is null, the specified
name
is returned unaltered; otherwise it is converted according to the JsonNamingPolicy.
Remarks
A convenient way of defining the property name according to Microsoft design decisions.