confluent-kafka-dotnet
Show / Hide Table of Contents

Class JsonDeserializer<T>

(async) JSON deserializer.

Inheritance
object
AsyncSerde<JsonSchema>
AsyncDeserializer<T, JsonSchema>
JsonDeserializer<T>
Implements
IAsyncDeserializer<T>
Inherited Members
AsyncDeserializer<T, JsonSchema>.headerSize
AsyncDeserializer<T, JsonSchema>.DeserializeAsync(ReadOnlyMemory<byte>, bool, SerializationContext)
AsyncSerde<JsonSchema>.schemaRegistryClient
AsyncSerde<JsonSchema>.ruleExecutors
AsyncSerde<JsonSchema>.useLatestVersion
AsyncSerde<JsonSchema>.latestCompatibilityStrict
AsyncSerde<JsonSchema>.useLatestWithMetadata
AsyncSerde<JsonSchema>.subjectNameStrategy
AsyncSerde<JsonSchema>.serdeMutex
AsyncSerde<JsonSchema>.GetSchema(string, int, string)
AsyncSerde<JsonSchema>.GetParsedSchema(Schema)
AsyncSerde<JsonSchema>.ResolveReferences(Schema)
AsyncSerde<JsonSchema>.GetMigrations(string, Schema, Schema)
AsyncSerde<JsonSchema>.GetReaderSchema(string, Schema)
AsyncSerde<JsonSchema>.ExecuteMigrations(IList<Migration>, bool, string, string, Headers, object)
AsyncSerde<JsonSchema>.ExecuteRules(bool, string, string, Headers, RuleMode, Schema, Schema, object, FieldTransformer)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Json.dll
Syntax
public class JsonDeserializer<T> : AsyncDeserializer<T, JsonSchema>, IAsyncDeserializer<T> where T : class
Type Parameters
Name Description
T
Remarks

Serialization format: byte 0: A magic byte that identifies this as a message with Confluent Platform framing. bytes 1-4: Unique global id of the JSON schema associated with the data (as registered in Confluent Schema Registry), big endian. following bytes: The JSON data (utf8)

Internally, uses Newtonsoft.Json for deserialization. Currently, no explicit validation of the data is done against the schema stored in Schema Registry.

Note: Off-the-shelf libraries do not yet exist to enable integration of System.Text.Json and JSON Schema, so this is not yet supported by the deserializer.

Constructors

JsonDeserializer(ISchemaRegistryClient, Schema, IEnumerable<KeyValuePair<string, string>>, JsonSchemaGeneratorSettings)

Initialize a new JsonDeserializer instance with a given Schema.

Declaration
public JsonDeserializer(ISchemaRegistryClient schemaRegistryClient, Schema schema, IEnumerable<KeyValuePair<string, string>> config = null, JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings = null)
Parameters
Type Name Description
ISchemaRegistryClient schemaRegistryClient

Confluent Schema Registry client instance.

Schema schema

Schema to use for validation, used when external schema references are present in the schema. Populate the References list of the schema for the same. Assuming the referenced schemas have already been registered in the registry.

IEnumerable<KeyValuePair<string, string>> config

Deserializer configuration properties (refer to JsonDeserializerConfig).

JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings

JSON schema generator settings.

JsonDeserializer(ISchemaRegistryClient, JsonDeserializerConfig, JsonSchemaGeneratorSettings, IList<IRuleExecutor>)

Declaration
public JsonDeserializer(ISchemaRegistryClient schemaRegistryClient, JsonDeserializerConfig config, JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings = null, IList<IRuleExecutor> ruleExecutors = null)
Parameters
Type Name Description
ISchemaRegistryClient schemaRegistryClient
JsonDeserializerConfig config
JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings
IList<IRuleExecutor> ruleExecutors

JsonDeserializer(ISchemaRegistryClient, IEnumerable<KeyValuePair<string, string>>, JsonSchemaGeneratorSettings)

Declaration
public JsonDeserializer(ISchemaRegistryClient schemaRegistryClient, IEnumerable<KeyValuePair<string, string>> config = null, JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings = null)
Parameters
Type Name Description
ISchemaRegistryClient schemaRegistryClient
IEnumerable<KeyValuePair<string, string>> config
JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings

JsonDeserializer(IEnumerable<KeyValuePair<string, string>>, JsonSchemaGeneratorSettings)

Initialize a new JsonDeserializer instance.

Declaration
public JsonDeserializer(IEnumerable<KeyValuePair<string, string>> config = null, JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings = null)
Parameters
Type Name Description
IEnumerable<KeyValuePair<string, string>> config

Deserializer configuration properties (refer to JsonDeserializerConfig).

JsonSchemaGeneratorSettings jsonSchemaGeneratorSettings

JSON schema generator settings.

Methods

DeserializeAsync(ReadOnlyMemory<byte>, bool, SerializationContext)

Deserialize an object of type T from a byte array.

Declaration
public override Task<T> DeserializeAsync(ReadOnlyMemory<byte> data, bool isNull, SerializationContext context)
Parameters
Type Name Description
ReadOnlyMemory<byte> data

The raw byte data to deserialize.

bool isNull

True if this is a null value.

SerializationContext context

Context relevant to the deserialize operation.

Returns
Type Description
Task<T>

A Task that completes with the deserialized value.

Overrides
AsyncDeserializer<T, JsonSchema>.DeserializeAsync(ReadOnlyMemory<byte>, bool, SerializationContext)

ParseSchema(Schema)

Declaration
protected override Task<JsonSchema> ParseSchema(Schema schema)
Parameters
Type Name Description
Schema schema
Returns
Type Description
Task<JsonSchema>
Overrides
AsyncSerde<JsonSchema>.ParseSchema(Schema)

Implements

IAsyncDeserializer<T>

Extension Methods

SyncOverAsyncDeserializerExtensionMethods.AsSyncOverAsync<T>(IAsyncDeserializer<T>)
In this article