Package org.eclipse.yasson.internal
Class JsonBinding
- java.lang.Object
-
- org.eclipse.yasson.internal.JsonBinding
-
- All Implemented Interfaces:
AutoCloseable
,javax.json.bind.Jsonb
,YassonJsonb
public class JsonBinding extends Object implements YassonJsonb
Implementation of Jsonb interface.- Author:
- Dmitry Kornilov
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected Map<String,?>
createJsonpProperties(javax.json.bind.JsonbConfig jsonbConfig)
Propagates properties from JsonbConfig to JSONP generator / parser factories.<T> T
fromJson(InputStream stream, Class<T> clazz)
<T> T
fromJson(InputStream stream, Type type)
<T> T
fromJson(Reader reader, Class<T> type)
<T> T
fromJson(Reader reader, Type type)
<T> T
fromJson(String str, Class<T> type)
<T> T
fromJson(String str, Type type)
<T> T
fromJson(javax.json.stream.JsonParser jsonParser, Class<T> type)
Reads in a JSON data with a specifiedJsonParser
and return the resulting content tree.<T> T
fromJson(javax.json.stream.JsonParser jsonParser, Type runtimeType)
Reads in a JSON data with a specifiedJsonParser
and return the resulting content tree.<T> T
fromJsonStructure(javax.json.JsonStructure jsonStructure, Class<T> type)
Reads aJsonStructure
and and converts it into resulting java content tree.<T> T
fromJsonStructure(javax.json.JsonStructure jsonStructure, Type runtimeType)
Reads aJsonStructure
and and converts it into resulting java content tree.String
toJson(Object object)
void
toJson(Object object, OutputStream stream)
void
toJson(Object object, Writer writer)
String
toJson(Object object, Type type)
void
toJson(Object object, Type type, OutputStream stream)
void
toJson(Object object, Type type, Writer writer)
void
toJson(Object object, Type runtimeType, javax.json.stream.JsonGenerator jsonGenerator)
Writes the object content tree with a specifiedJsonGenerator
.void
toJson(Object object, javax.json.stream.JsonGenerator jsonGenerator)
Writes the object content tree with a specifiedJsonGenerator
.javax.json.JsonStructure
toJsonStructure(Object object)
Serializes the object content tree to aJsonStructure
.javax.json.JsonStructure
toJsonStructure(Object object, Type runtimeType)
Serializes the object content tree to aJsonStructure
.
-
-
-
Method Detail
-
fromJson
public <T> T fromJson(String str, Class<T> type) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(String str, Type type) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(Reader reader, Class<T> type) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(Reader reader, Type type) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(InputStream stream, Class<T> clazz) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(InputStream stream, Type type) throws javax.json.bind.JsonbException
- Specified by:
fromJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJsonStructure
public <T> T fromJsonStructure(javax.json.JsonStructure jsonStructure, Class<T> type) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Reads aJsonStructure
and and converts it into resulting java content tree.- Specified by:
fromJsonStructure
in interfaceYassonJsonb
- Type Parameters:
T
- Type of the content tree's root object.- Parameters:
jsonStructure
-JsonStructure
to be used as a source for conversion.type
- Type of the content tree's root object.- Returns:
- the newly created root object of the java content tree
- Throws:
javax.json.bind.JsonbException
- If any unexpected error(s) occur(s) during conversion.
-
fromJsonStructure
public <T> T fromJsonStructure(javax.json.JsonStructure jsonStructure, Type runtimeType) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Reads aJsonStructure
and and converts it into resulting java content tree.- Specified by:
fromJsonStructure
in interfaceYassonJsonb
- Type Parameters:
T
- Type of the content tree's root object.- Parameters:
jsonStructure
-JsonStructure
to be used as a source for conversion.runtimeType
- Runtime type of the content tree's root object.- Returns:
- the newly created root object of the java content tree
- Throws:
javax.json.bind.JsonbException
- If any unexpected error(s) occur(s) during deserialization.
-
toJson
public String toJson(Object object) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
toJson
public String toJson(Object object, Type type) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
toJson
public void toJson(Object object, Writer writer) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
toJson
public void toJson(Object object, Type type, Writer writer) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
toJson
public void toJson(Object object, OutputStream stream) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
toJson
public void toJson(Object object, Type type, OutputStream stream) throws javax.json.bind.JsonbException
- Specified by:
toJson
in interfacejavax.json.bind.Jsonb
- Throws:
javax.json.bind.JsonbException
-
fromJson
public <T> T fromJson(javax.json.stream.JsonParser jsonParser, Class<T> type) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Reads in a JSON data with a specifiedJsonParser
and return the resulting content tree. Provided json parser must be fully initialized, no further configurations will be applied.- Specified by:
fromJson
in interfaceYassonJsonb
- Type Parameters:
T
- Type of the content tree's root object.- Parameters:
jsonParser
- The json parser instance to be used to read JSON data.type
- Type of the content tree's root object.- Returns:
- the newly created root object of the java content tree
- Throws:
javax.json.bind.JsonbException
- If any unexpected error(s) occur(s) during deserialization.
-
fromJson
public <T> T fromJson(javax.json.stream.JsonParser jsonParser, Type runtimeType) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Reads in a JSON data with a specifiedJsonParser
and return the resulting content tree. Provided json parser must be fully initialized, no further configurations will be applied.- Specified by:
fromJson
in interfaceYassonJsonb
- Type Parameters:
T
- Type of the content tree's root object.- Parameters:
jsonParser
- The json parser instance to be used to read JSON data.runtimeType
- Runtime type of the content tree's root object.- Returns:
- the newly created root object of the java content tree
- Throws:
javax.json.bind.JsonbException
- If any unexpected error(s) occur(s) during deserialization.
-
toJson
public void toJson(Object object, javax.json.stream.JsonGenerator jsonGenerator) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Writes the object content tree with a specifiedJsonGenerator
. Provided json generator must be fully initialized, no further configurations are applied.- Specified by:
toJson
in interfaceYassonJsonb
- Parameters:
object
- The object content tree to be serialized.jsonGenerator
- The json generator to write JSON data. The generator is not closed on a completion for further interaction.- Throws:
javax.json.bind.JsonbException
- If any unexpected problem occurs during the serialization.
-
toJson
public void toJson(Object object, Type runtimeType, javax.json.stream.JsonGenerator jsonGenerator) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Writes the object content tree with a specifiedJsonGenerator
. Provided json generator must be fully initialized, no further configurations are applied.- Specified by:
toJson
in interfaceYassonJsonb
- Parameters:
object
- The object content tree to be serialized.runtimeType
- Runtime type of the content tree's root object.jsonGenerator
- The json generator to write JSON data. The generator is not closed on a completion for further interaction.- Throws:
javax.json.bind.JsonbException
- If any unexpected problem occurs during the serialization.
-
toJsonStructure
public javax.json.JsonStructure toJsonStructure(Object object) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Serializes the object content tree to aJsonStructure
.- Specified by:
toJsonStructure
in interfaceYassonJsonb
- Parameters:
object
- The object content tree to be serialized.- Returns:
- The
JsonStructure
serialized from java content tree. - Throws:
javax.json.bind.JsonbException
- If any unexpected problem occurs during the serialization.
-
toJsonStructure
public javax.json.JsonStructure toJsonStructure(Object object, Type runtimeType) throws javax.json.bind.JsonbException
Description copied from interface:YassonJsonb
Serializes the object content tree to aJsonStructure
.- Specified by:
toJsonStructure
in interfaceYassonJsonb
- Parameters:
object
- The object content tree to be serialized.runtimeType
- Runtime type of the content tree's root object.- Returns:
- The
JsonStructure
serialized from java content tree. - Throws:
javax.json.bind.JsonbException
- If any unexpected problem occurs during the serialization.
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-