Table of Contents

Class JsonSupport

Namespace
MASES.EntityFrameworkCore.KNet.Serialization
Assembly
MASES.EntityFrameworkCore.KNet.Serialization.dll

An helper class to centralize management of every Json conversion for DefaultKEFCoreSerDes or any other serialization sub-system which needs Json conversion (typically when there isn't any IComplexTypeConverter available in IComplexTypeConverterFactory instance)

public class JsonSupport
Inheritance
JsonSupport
Inherited Members

Fields

DefautJsonOptions

The JsonSerializerOptions used for serialization/deserialization

public readonly JsonSerializerOptions? DefautJsonOptions

Field Value

JsonSerializerOptions

Properties

Key

JsonSupport istance for keys

public static JsonSupport Key { get; }

Property Value

JsonSupport

ValueContainer

JsonSupport istance for IValueContainer<T> instances

public static JsonSupport ValueContainer { get; }

Property Value

JsonSupport

Methods

Deserialize(Type, ByteBuffer)

Reads the UTF-8 encoded text representing a single JSON value into a returnType. The Stream will be read to completion.

public object Deserialize(Type type, ByteBuffer data)

Parameters

type Type
data ByteBuffer

Returns

object

A returnType representation of the JSON value.

Exceptions

ArgumentNullException

utf8Json or returnType is null.

JsonException

The JSON is invalid, the returnType is not compatible with the JSON, or there is remaining data in the Stream.

NotSupportedException

There is no compatible JsonConverter for returnType or its serializable members.

Deserialize(Type, byte[])

Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.

public object Deserialize(Type type, byte[] data)

Parameters

type Type
data byte[]

Returns

object

A returnType representation of the JSON value.

Exceptions

ArgumentNullException

returnType is null.

JsonException

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

NotSupportedException

There is no compatible for returnType or its serializable members.

Deserialize(Type, string)

Parses the text representing a single JSON value into an instance of a specified type.

public object Deserialize(Type type, string data)

Parameters

type Type
data string

Returns

object

A returnType representation of the JSON value.

Exceptions

ArgumentNullException

json or returnType is null.

JsonException

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

NotSupportedException

There is no compatible for returnType or its serializable members.

Deserialize<TData>(ByteBuffer)

Reads the UTF-8 encoded text representing a single JSON value into a TValue. The Stream will be read to completion.

public TData Deserialize<TData>(ByteBuffer data)

Parameters

data ByteBuffer

Returns

TData

A TValue representation of the JSON value.

Type Parameters

TData

Exceptions

ArgumentNullException

utf8Json is null.

JsonException

The JSON is invalid, TValue is not compatible with the JSON, or there is remaining data in the Stream.

NotSupportedException

There is no compatible JsonConverter for TValue or its serializable members.

Deserialize<TData>(byte[])

Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.

public TData Deserialize<TData>(byte[] data)

Parameters

data byte[]

Returns

TData

A TValue representation of the JSON value.

Type Parameters

TData

Exceptions

JsonException

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

NotSupportedException

There is no compatible for TValue or its serializable members.

Deserialize<TData>(string)

Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

public TData Deserialize<TData>(string data)

Parameters

data string

Returns

TData

A TValue representation of the JSON value.

Type Parameters

TData

Exceptions

ArgumentNullException

json is null.

JsonException

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

NotSupportedException

There is no compatible for TValue or its serializable members.

Serialize(Type, object)

Converts the value of a specified type into a JSON string.

public string Serialize(Type type, object data)

Parameters

type Type
data object

Returns

string

The JSON string representation of the value.

Exceptions

ArgumentException

inputType is not compatible with value.

ArgumentNullException

inputType is null.

NotSupportedException

There is no compatible for inputType or its serializable members.

SerializeAsByteBuffer(Type, object)

Converts the provided value to UTF-8 encoded JSON text and write it to the Stream.

public byte[] SerializeAsByteBuffer(Type type, object data)

Parameters

type Type
data object

Returns

byte[]

Exceptions

ArgumentException

inputType is not compatible with value.

ArgumentNullException

utf8Json or inputType is null.

NotSupportedException

There is no compatible JsonConverter for inputType or its serializable members.

SerializeAsByteBuffer<TData>(TData)

Converts the provided value to UTF-8 encoded JSON text and write it to the Stream.

public byte[] SerializeAsByteBuffer<TData>(TData data)

Parameters

data TData

Returns

byte[]

Type Parameters

TData

Exceptions

ArgumentNullException

utf8Json is null.

NotSupportedException

There is no compatible JsonConverter for TValue or its serializable members.

SerializeAsBytes(Type, object)

Converts the value of a specified type into a JSON string.

public byte[] SerializeAsBytes(Type type, object data)

Parameters

type Type
data object

Returns

byte[]

The JSON string representation of the value.

Exceptions

ArgumentException

inputType is not compatible with value.

ArgumentNullException

inputType is null.

NotSupportedException

There is no compatible for inputType or its serializable members.

SerializeAsBytes<TData>(TData)

Converts the value of a type specified by a generic type parameter into a JSON string.

public byte[] SerializeAsBytes<TData>(TData data)

Parameters

data TData

Returns

byte[]

A JSON string representation of the value.

Type Parameters

TData

Exceptions

NotSupportedException

There is no compatible for TValue or its serializable members.

Serialize<TData>(TData)

Converts the value of a type specified by a generic type parameter into a JSON string.

public string Serialize<TData>(TData data)

Parameters

data TData

Returns

string

A JSON string representation of the value.

Type Parameters

TData

Exceptions

NotSupportedException

There is no compatible for TValue or its serializable members.