Class JsonBinding

  • All Implemented Interfaces:
    java.lang.AutoCloseable, javax.json.bind.Jsonb, YassonJsonb

    public class JsonBinding
    extends java.lang.Object
    implements YassonJsonb
    Implementation of Jsonb interface.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected java.util.Map<java.lang.String,​?> createJsonpProperties​(javax.json.bind.JsonbConfig jsonbConfig)
      Propagates properties from JsonbConfig to JSONP generator / parser factories.
      <T> T fromJson​(java.io.InputStream stream, java.lang.Class<T> clazz)  
      <T> T fromJson​(java.io.InputStream stream, java.lang.reflect.Type type)  
      <T> T fromJson​(java.io.Reader reader, java.lang.Class<T> type)  
      <T> T fromJson​(java.io.Reader reader, java.lang.reflect.Type type)  
      <T> T fromJson​(java.lang.String str, java.lang.Class<T> type)  
      <T> T fromJson​(java.lang.String str, java.lang.reflect.Type type)  
      <T> T fromJson​(javax.json.stream.JsonParser jsonParser, java.lang.Class<T> type)
      Reads in a JSON data with a specified JsonParser and return the resulting content tree.
      <T> T fromJson​(javax.json.stream.JsonParser jsonParser, java.lang.reflect.Type runtimeType)
      Reads in a JSON data with a specified JsonParser and return the resulting content tree.
      <T> T fromJsonStructure​(javax.json.JsonStructure jsonStructure, java.lang.Class<T> type)
      Reads a JsonStructure and and converts it into resulting java content tree.
      <T> T fromJsonStructure​(javax.json.JsonStructure jsonStructure, java.lang.reflect.Type runtimeType)
      Reads a JsonStructure and and converts it into resulting java content tree.
      java.lang.String toJson​(java.lang.Object object)  
      void toJson​(java.lang.Object object, java.io.OutputStream stream)  
      void toJson​(java.lang.Object object, java.io.Writer writer)  
      java.lang.String toJson​(java.lang.Object object, java.lang.reflect.Type type)  
      void toJson​(java.lang.Object object, java.lang.reflect.Type type, java.io.OutputStream stream)  
      void toJson​(java.lang.Object object, java.lang.reflect.Type type, java.io.Writer writer)  
      void toJson​(java.lang.Object object, java.lang.reflect.Type runtimeType, javax.json.stream.JsonGenerator jsonGenerator)
      Writes the object content tree with a specified JsonGenerator.
      void toJson​(java.lang.Object object, javax.json.stream.JsonGenerator jsonGenerator)
      Writes the object content tree with a specified JsonGenerator.
      javax.json.JsonStructure toJsonStructure​(java.lang.Object object)
      Serializes the object content tree to a JsonStructure.
      javax.json.JsonStructure toJsonStructure​(java.lang.Object object, java.lang.reflect.Type runtimeType)
      Serializes the object content tree to a JsonStructure.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • fromJson

        public <T> T fromJson​(java.lang.String str,
                              java.lang.Class<T> type)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(java.lang.String str,
                              java.lang.reflect.Type type)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(java.io.Reader reader,
                              java.lang.Class<T> type)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(java.io.Reader reader,
                              java.lang.reflect.Type type)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(java.io.InputStream stream,
                              java.lang.Class<T> clazz)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(java.io.InputStream stream,
                              java.lang.reflect.Type type)
                       throws javax.json.bind.JsonbException
        Specified by:
        fromJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJsonStructure

        public <T> T fromJsonStructure​(javax.json.JsonStructure jsonStructure,
                                       java.lang.Class<T> type)
                                throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Reads a JsonStructure and and converts it into resulting java content tree.
        Specified by:
        fromJsonStructure in interface YassonJsonb
        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,
                                       java.lang.reflect.Type runtimeType)
                                throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Reads a JsonStructure and and converts it into resulting java content tree.
        Specified by:
        fromJsonStructure in interface YassonJsonb
        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 java.lang.String toJson​(java.lang.Object object)
                                throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • toJson

        public java.lang.String toJson​(java.lang.Object object,
                                       java.lang.reflect.Type type)
                                throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • toJson

        public void toJson​(java.lang.Object object,
                           java.io.Writer writer)
                    throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • toJson

        public void toJson​(java.lang.Object object,
                           java.lang.reflect.Type type,
                           java.io.Writer writer)
                    throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • toJson

        public void toJson​(java.lang.Object object,
                           java.io.OutputStream stream)
                    throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • toJson

        public void toJson​(java.lang.Object object,
                           java.lang.reflect.Type type,
                           java.io.OutputStream stream)
                    throws javax.json.bind.JsonbException
        Specified by:
        toJson in interface javax.json.bind.Jsonb
        Throws:
        javax.json.bind.JsonbException
      • fromJson

        public <T> T fromJson​(javax.json.stream.JsonParser jsonParser,
                              java.lang.Class<T> type)
                       throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Reads in a JSON data with a specified JsonParser and return the resulting content tree. Provided json parser must be fully initialized, no further configurations will be applied.
        Specified by:
        fromJson in interface YassonJsonb
        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,
                              java.lang.reflect.Type runtimeType)
                       throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Reads in a JSON data with a specified JsonParser and return the resulting content tree. Provided json parser must be fully initialized, no further configurations will be applied.
        Specified by:
        fromJson in interface YassonJsonb
        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​(java.lang.Object object,
                           javax.json.stream.JsonGenerator jsonGenerator)
                    throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Writes the object content tree with a specified JsonGenerator. Provided json generator must be fully initialized, no further configurations are applied.
        Specified by:
        toJson in interface YassonJsonb
        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​(java.lang.Object object,
                           java.lang.reflect.Type runtimeType,
                           javax.json.stream.JsonGenerator jsonGenerator)
                    throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Writes the object content tree with a specified JsonGenerator. Provided json generator must be fully initialized, no further configurations are applied.
        Specified by:
        toJson in interface YassonJsonb
        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​(java.lang.Object object)
                                                 throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Serializes the object content tree to a JsonStructure.
        Specified by:
        toJsonStructure in interface YassonJsonb
        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​(java.lang.Object object,
                                                        java.lang.reflect.Type runtimeType)
                                                 throws javax.json.bind.JsonbException
        Description copied from interface: YassonJsonb
        Serializes the object content tree to a JsonStructure.
        Specified by:
        toJsonStructure in interface YassonJsonb
        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 java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • createJsonpProperties

        protected java.util.Map<java.lang.String,​?> createJsonpProperties​(javax.json.bind.JsonbConfig jsonbConfig)
        Propagates properties from JsonbConfig to JSONP generator / parser factories.
        Parameters:
        jsonbConfig - jsonb config
        Returns:
        properties for JSONP generator / parser