Compartilhar via


JsonSerializer Interface

Implements

public interface JsonSerializer
extends ObjectSerializer

Generic interface covering basic JSON serialization and deserialization methods.

Method Summary

Modifier and Type Method and Description
abstract T deserialize(InputStream stream, TypeReference<T> typeReference)

Reads a JSON stream into its object representation.

abstract Mono<T> deserializeAsync(InputStream stream, TypeReference<T> typeReference)

Reads a JSON stream into its object representation.

default T deserializeFromBytes(byte[] data, TypeReference<T> typeReference)

Reads a JSON byte array into its object representation.

default Mono<T> deserializeFromBytesAsync(byte[] data, TypeReference<T> typeReference)

Reads a JSON byte array into its object representation.

abstract void serialize(OutputStream stream, Object value)

Writes an object's JSON representation into a stream.

abstract Mono<Void> serializeAsync(OutputStream stream, Object value)

Writes an object's JSON representation into a stream.

default byte[] serializeToBytes(Object value)

Converts the object into a JSON byte array.

default Mono<byte[]> serializeToBytesAsync(Object value)

Converts the object into a JSON byte array.

Method Details

deserialize

public abstract T deserialize(InputStream stream, TypeReference typeReference)

Reads a JSON stream into its object representation.

Parameters:

stream - JSON stream.
typeReference - TypeReference<T> representing the object.

Returns:

The object represented by the deserialized JSON stream.

deserializeAsync

public abstract Mono deserializeAsync(InputStream stream, TypeReference typeReference)

Reads a JSON stream into its object representation.

Parameters:

stream - JSON stream.
typeReference - TypeReference<T> representing the object.

Returns:

Reactive stream that emits the object represented by the deserialized JSON stream.

deserializeFromBytes

public default T deserializeFromBytes(byte[] data, TypeReference typeReference)

Reads a JSON byte array into its object representation.

Parameters:

data - JSON byte array.
typeReference - TypeReference<T> representing the object.

Returns:

The object represented by the deserialized JSON byte array.

deserializeFromBytesAsync

public default Mono deserializeFromBytesAsync(byte[] data, TypeReference typeReference)

Reads a JSON byte array into its object representation.

Parameters:

data - JSON byte array.
typeReference - TypeReference<T> representing the object.

Returns:

Reactive stream that emits the object represented by the deserialized JSON byte array.

serialize

public abstract void serialize(OutputStream stream, Object value)

Writes an object's JSON representation into a stream.

Parameters:

stream - OutputStream where the object's JSON representation will be written.
value - The object.

serializeAsync

public abstract Mono serializeAsync(OutputStream stream, Object value)

Writes an object's JSON representation into a stream.

Parameters:

stream - OutputStream where the object's JSON representation will be written.
value - The object.

Returns:

Reactive stream that will indicate operation completion.

serializeToBytes

public default byte[] serializeToBytes(Object value)

Converts the object into a JSON byte array.

Parameters:

value - The object.

Returns:

The JSON binary representation of the serialized object.

serializeToBytesAsync

public default Mono serializeToBytesAsync(Object value)

Converts the object into a JSON byte array.

Parameters:

value - The object.

Returns:

Reactive stream that emits the JSON binary representation of the serialized object.

Applies to