Home ValidatingJsonConverter Class
ValidatingJsonConverter Class
Cancel

ValidatingJsonConverter Class

Namespace: Json.Schema.Serialization

Inheritance: ValidatingJsonConverter<T> 🡒 WeaklyTypedJsonConverter<T> 🡒 JsonConverter<T> 🡒 JsonConverter 🡒 object

Implemented interfaces:

  • IWeaklyTypedJsonConverter
  • IValidatingJsonConverter

DO NOT USE THIS CLASS DIRECTLY. INSTEAD, REGISTER THE NON-GENERIC CONVERTER WITH YOUR SERIALIZER OPTIONS. Validates JSON against a schema during deserialization.

Properties

NameTypeSummary
HandleNullbool 
OptionsEvaluationOptionsGets or sets the evaluation options for schema validation.
TypeType 

Constructors

ValidatingJsonConverter<T>(JsonSchema schema, Func<JsonSerializerOptions, JsonSerializerOptions> optionsFactory)

Creates a new instance of Json.Schema.Serialization.ValidatingJsonConverter`1.

Declaration

1
public ValidatingJsonConverter`1(JsonSchema schema, Func<JsonSerializerOptions, JsonSerializerOptions> optionsFactory)
ParameterTypeDescription
schemaJsonSchemaThe JSON schema to validate against.
optionsFactoryFunc<JsonSerializerOptions, JsonSerializerOptions>A factory function to create serializer options without validating converters to avoid recursion.

Methods

Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Reads and validates JSON data against the schema.

Declaration

1
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
ParameterTypeDescription
readerref Utf8JsonReaderThe reader to use for reading JSON.
typeToConvertTypeThe type to convert to.
optionsJsonSerializerOptionsThe serializer options.

Returns

The deserialized object.

Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)

Writes the JSON representation of the object.

Declaration

1
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
ParameterTypeDescription
writerUtf8JsonWriterThe writer to use for writing JSON.
valueTThe value to serialize.
optionsJsonSerializerOptionsThe serializer options.
Contents