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
Properties
Key
JsonSupport istance for keys
public static JsonSupport Key { get; }
Property Value
ValueContainer
JsonSupport istance for IValueContainer<T> instances
public static JsonSupport ValueContainer { get; }
Property Value
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
typeTypedataByteBuffer
Returns
- object
A
returnTyperepresentation of the JSON value.
Exceptions
- ArgumentNullException
utf8JsonorreturnTypeis null.- JsonException
The JSON is invalid, the
returnTypeis not compatible with the JSON, or there is remaining data in the Stream.- NotSupportedException
There is no compatible JsonConverter for
returnTypeor 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
Returns
- object
A
returnTyperepresentation of the JSON value.
Exceptions
- ArgumentNullException
returnTypeis null.- JsonException
The JSON is invalid.
-or-
returnTypeis not compatible with the JSON.-or-
There is remaining data in the span beyond a single JSON value.
- NotSupportedException
There is no compatible
for returnTypeor 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
Returns
- object
A
returnTyperepresentation of the JSON value.
Exceptions
- ArgumentNullException
jsonorreturnTypeis null.- JsonException
The JSON is invalid.
-or-
TValueis not compatible with the JSON.-or-
There is remaining data in the string beyond a single JSON value.
- NotSupportedException
There is no compatible
for returnTypeor 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
dataByteBuffer
Returns
- TData
A
TValuerepresentation of the JSON value.
Type Parameters
TData
Exceptions
- ArgumentNullException
utf8Jsonis null.- JsonException
The JSON is invalid,
TValueis not compatible with the JSON, or there is remaining data in the Stream.- NotSupportedException
There is no compatible JsonConverter for
TValueor 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
databyte[]
Returns
- TData
A
TValuerepresentation of the JSON value.
Type Parameters
TData
Exceptions
- JsonException
The JSON is invalid.
-or-
TValueis not compatible with the JSON.-or-
There is remaining data in the span beyond a single JSON value.
- NotSupportedException
There is no compatible
for TValueor 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
datastring
Returns
- TData
A
TValuerepresentation of the JSON value.
Type Parameters
TData
Exceptions
- ArgumentNullException
jsonis null.- JsonException
The JSON is invalid.
-or-
TValueis not compatible with the JSON.-or-
There is remaining data in the string beyond a single JSON value.
- NotSupportedException
There is no compatible
for TValueor 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
Returns
- string
The JSON string representation of the value.
Exceptions
- ArgumentException
inputTypeis not compatible withvalue.- ArgumentNullException
inputTypeis null.- NotSupportedException
There is no compatible
for inputTypeor 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
Returns
- byte[]
Exceptions
- ArgumentException
inputTypeis not compatible withvalue.- ArgumentNullException
utf8JsonorinputTypeis null.- NotSupportedException
There is no compatible JsonConverter for
inputTypeor 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
dataTData
Returns
- byte[]
Type Parameters
TData
Exceptions
- ArgumentNullException
utf8Jsonis null.- NotSupportedException
There is no compatible JsonConverter for
TValueor 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
Returns
- byte[]
The JSON string representation of the value.
Exceptions
- ArgumentException
inputTypeis not compatible withvalue.- ArgumentNullException
inputTypeis null.- NotSupportedException
There is no compatible
for inputTypeor 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
dataTData
Returns
- byte[]
A JSON string representation of the value.
Type Parameters
TData
Exceptions
- NotSupportedException
There is no compatible
for TValueor 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
dataTData
Returns
- string
A JSON string representation of the value.
Type Parameters
TData
Exceptions
- NotSupportedException
There is no compatible
for TValueor its serializable members.