org.qi4j.valueserialization.orgjson

## Class OrgJsonValueSerialization

- java.lang.Object
- - org.qi4j.valueserialization.orgjson.OrgJsonValueSerialization

- All Implemented Interfaces:
    ValueDeserializer, ValueSerialization, ValueSerializer

      public class OrgJsonValueSerialization
      extends Object
      implements ValueSerialization

  ValueSerialization producing and consuming JSON documents using org.json.

  This class is used internally by the Zest Runtime to provide default ValueSerialization when no ValueSerialization Service is available.

  In application code, prefer the use of `OrgJsonValueSerializationService`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.qi4j.api.value.ValueSerialization

      `ValueSerialization.Formats`

    - ### Nested classes/interfaces inherited from interface org.qi4j.api.value.ValueSerializer

      `ValueSerializer.Options`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OrgJsonValueSerialization(Application application, Module module, Module valuesModule)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> Function2<ValueType,String,T>` | `deserialize()` Factory method for an untyped deserialize function.
    `<T> T` | `deserialize(Class<?> type, InputStream input)` Deserialize a value from a state.
    `<T> T` | `deserialize(Class<?> type, String input)` Deserialize a value from a state.
    `<T> Function<String,T>` | `deserialize(Class<T> type)` Factory method for a typed deserialize function.
    `<T> Function<String,T>` | `deserialize(ValueType valueType)` Factory method for a typed deserialize function.
    `<T> T` | `deserialize(ValueType type, InputStream input)` Deserialize a value from a state.
    `<T> T` | `deserialize(ValueType type, String input)` Deserialize a value from a state.
    `<T> Function<T,String>` | `serialize()` Factory method for a serialize function.
    `<T> Function<T,String>` | `serialize(boolean includeTypeInfo)` Deprecated.
    `String` | `serialize(Object object)` Serialize the state of a value with type information.
    `String` | `serialize(Object object, boolean includeTypeInfo)` Deprecated.
    `void` | `serialize(Object object, OutputStream output)` Serialize the state of a value with type information.
    `void` | `serialize(Object object, OutputStream output, boolean includeTypeInfo)` Deprecated.
    `<T> Function<T,String>` | `serialize(ValueSerializer.Options options)` Factory method for a serialize function.
    `String` | `serialize(ValueSerializer.Options options, Object object)` Serialize the state of a value.
    `void` | `serialize(ValueSerializer.Options options, Object object, OutputStream output)` Serialize the state of a value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OrgJsonValueSerialization

          public OrgJsonValueSerialization(Application application,
                                   Module module,
                                   Module valuesModule)

  - ### Method Detail

    - #### serialize

          public <T> Function<T,String> serialize()

      Description copied from interface: `ValueSerializer`
      Factory method for a serialize function.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Type Parameters:
        `T` - the parametrized function input type
      Returns:
        a serialization function.

    - #### serialize

          public <T> Function<T,String> serialize(ValueSerializer.Options options)

      Description copied from interface: `ValueSerializer`
      Factory method for a serialize function.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Type Parameters:
        `T` - the parametrized function input type
      Parameters:
        `options` - ValueSerializer Options
      Returns:
        a serialization function.

    - #### serialize

          @Deprecated
          public <T> Function<T,String> serialize(boolean includeTypeInfo)

      Deprecated.
      Description copied from interface: `ValueSerializer`
      Factory method for a serialize function.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Type Parameters:
        `T` - the parametrized function input type
      Parameters:
        `includeTypeInfo` - if type information should be included in the output
      Returns:
        a serialization function.

    - #### serialize

          public String serialize(Object object)
                           throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value with type information.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `object` - an Object to serialize
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          public String serialize(ValueSerializer.Options options,
                         Object object)
                           throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          public String serialize(Object object,
                                    boolean includeTypeInfo)
                           throws ValueSerializationException

      Deprecated.
      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `object` - an Object to serialize
        `includeTypeInfo` - if type information should be included in the output
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          public void serialize(Object object,
                       OutputStream output)
                         throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value with type information.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `object` - an Object to serialize
        `output` - that will be used as output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          public void serialize(ValueSerializer.Options options,
                       Object object,
                       OutputStream output)
                         throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
        `output` - that will be used as output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          public void serialize(Object object,
                                  OutputStream output,
                                  boolean includeTypeInfo)
                         throws ValueSerializationException

      Deprecated.
      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `object` - an Object to serialize
        `output` - that will be used as output
        `includeTypeInfo` - if type information should be included in the output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### deserialize

          public <T> Function<String,T> deserialize(Class<T> type)

      Description copied from interface: `ValueDeserializer`
      Factory method for a typed deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized function return type
      Parameters:
        `type` - the value type
      Returns:
        a deserialization function

    - #### deserialize

          public <T> Function<String,T> deserialize(ValueType valueType)

      Description copied from interface: `ValueDeserializer`
      Factory method for a typed deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized function return type
      Parameters:
        `valueType` - the value type
      Returns:
        a deserialization function

    - #### deserialize

          public <T> Function2<ValueType,String,T> deserialize()

      Description copied from interface: `ValueDeserializer`
      Factory method for an untyped deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized function return type
      Returns:
        a deserialization function

    - #### deserialize

          public <T> T deserialize(Class<?> type,
                          String input)
                        throws ValueSerializationException

      Description copied from interface: `ValueDeserializer`
      Deserialize a value from a state.
      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          public <T> T deserialize(ValueType type,
                          String input)
                        throws ValueSerializationException

      Description copied from interface: `ValueDeserializer`
      Deserialize a value from a state.
      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          public <T> T deserialize(Class<?> type,
                          InputStream input)
                        throws ValueSerializationException

      Description copied from interface: `ValueDeserializer`
      Deserialize a value from a state.
      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state stream
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          public <T> T deserialize(ValueType type,
                          InputStream input)
                        throws ValueSerializationException

      Description copied from interface: `ValueDeserializer`
      Deserialize a value from a state.
      Specified by:
        `deserialize` in interface `ValueDeserializer`
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state stream
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed