Package com.azure.core.util.serializer
Interface JsonSerializer
-
- All Superinterfaces:
ObjectSerializer
public interface JsonSerializer extends ObjectSerializer
Generic interface covering basic JSON serialization and deserialization methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> T
deserialize(InputStream stream, TypeReference<T> typeReference)
Reads a JSON stream into its object representation.<T> Mono<T>
deserializeAsync(InputStream stream, TypeReference<T> typeReference)
Reads a JSON stream into its object representation.default <T> T
deserializeFromBytes(byte[] data, TypeReference<T> typeReference)
Reads a JSON byte array into its object representation.default <T> Mono<T>
deserializeFromBytesAsync(byte[] data, TypeReference<T> typeReference)
Reads a JSON byte array into its object representation.void
serialize(OutputStream stream, Object value)
Writes an object's JSON representation into a stream.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 Detail
-
deserializeFromBytes
default <T> T deserializeFromBytes(byte[] data, TypeReference<T> typeReference)
Reads a JSON byte array into its object representation.- Specified by:
deserializeFromBytes
in interfaceObjectSerializer
- Type Parameters:
T
- Type of the object.- Parameters:
data
- JSON byte array.typeReference
-TypeReference
representing the object.- Returns:
- The object represented by the deserialized JSON byte array.
-
deserialize
<T> T deserialize(InputStream stream, TypeReference<T> typeReference)
Reads a JSON stream into its object representation.- Specified by:
deserialize
in interfaceObjectSerializer
- Type Parameters:
T
- Type of the object.- Parameters:
stream
- JSON stream.typeReference
-TypeReference
representing the object.- Returns:
- The object represented by the deserialized JSON stream.
-
deserializeFromBytesAsync
default <T> Mono<T> deserializeFromBytesAsync(byte[] data, TypeReference<T> typeReference)
Reads a JSON byte array into its object representation.- Specified by:
deserializeFromBytesAsync
in interfaceObjectSerializer
- Type Parameters:
T
- Type of the object.- Parameters:
data
- JSON byte array.typeReference
-TypeReference
representing the object.- Returns:
- Reactive stream that emits the object represented by the deserialized JSON byte array.
-
deserializeAsync
<T> Mono<T> deserializeAsync(InputStream stream, TypeReference<T> typeReference)
Reads a JSON stream into its object representation.- Specified by:
deserializeAsync
in interfaceObjectSerializer
- Type Parameters:
T
- Type of the object.- Parameters:
stream
- JSON stream.typeReference
-TypeReference
representing the object.- Returns:
- Reactive stream that emits the object represented by the deserialized JSON stream.
-
serializeToBytes
default byte[] serializeToBytes(Object value)
Converts the object into a JSON byte array.- Specified by:
serializeToBytes
in interfaceObjectSerializer
- Parameters:
value
- The object.- Returns:
- The JSON binary representation of the serialized object.
-
serialize
void serialize(OutputStream stream, Object value)
Writes an object's JSON representation into a stream.- Specified by:
serialize
in interfaceObjectSerializer
- Parameters:
stream
-OutputStream
where the object's JSON representation will be written.value
- The object.
-
serializeToBytesAsync
default Mono<byte[]> serializeToBytesAsync(Object value)
Converts the object into a JSON byte array.- Specified by:
serializeToBytesAsync
in interfaceObjectSerializer
- Parameters:
value
- The object.- Returns:
- Reactive stream that emits the JSON binary representation of the serialized object.
-
serializeAsync
Mono<Void> serializeAsync(OutputStream stream, Object value)
Writes an object's JSON representation into a stream.- Specified by:
serializeAsync
in interfaceObjectSerializer
- Parameters:
stream
-OutputStream
where the object's JSON representation will be written.value
- The object.- Returns:
- Reactive stream that will indicate operation completion.
-
-