com.holonplatform.json.gson.internal

## Class DefaultGsonJson

- java.lang.Object
- - com.holonplatform.json.gson.internal.DefaultGsonJson

- All Implemented Interfaces:
    GsonJson, Json

      public class DefaultGsonJson
      extends Object
      implements GsonJson

  Default `GsonJson` implementation.
  Since:
    5.1.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.holonplatform.json.Json

      `Json.JsonException, Json.JsonReadException, Json.JsonWriteException`

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.json.Json

      `CONTEXT_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultGsonJson(com.google.gson.Gson gson)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `fromJson(JsonReader reader, Class<T> type)` Deserializes the specified JSON source into an object of the specified type.
    `<P extends com.holonplatform.core.property.Property> com.holonplatform.core.property.PropertyBox` | `fromJson(JsonReader reader, Iterable<P> propertySet)` Deserializes the specified JSON data source into a `PropertyBox`, using given `propertySet` as `PropertyBox` property set.
    `<T> List<T>` | `fromJsonArray(JsonReader reader, Class<T> type)` Deserializes the specified JSON array data source into a `List` of objects of the specified type.
    `<P extends com.holonplatform.core.property.Property> List<com.holonplatform.core.property.PropertyBox>` | `fromJsonArray(JsonReader reader, Iterable<P> propertySet)` Deserializes the specified JSON array data source into a list of `PropertyBox`, using given `propertySet` as `PropertyBox` property set.
    `JsonWriter` | `toJson(Object value)` Serialize given `value` to JSON.
    `<T> JsonWriter` | `toJsonArray(Class<T> type, Collection<T> values)` Serialize given collection of values as a JSON array.

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

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

    - ### Methods inherited from interface com.holonplatform.json.gson.GsonJson

      `create, create`

    - ### Methods inherited from interface com.holonplatform.json.Json

      `fromJson, fromJson, fromJson, fromJson, fromJsonArray, fromJsonArray, fromJsonArray, fromJsonArray, get, get, require, toJsonArray, toJsonArrayString, toJsonArrayString, toJsonString`

- - ### Constructor Detail

    - #### DefaultGsonJson

          public DefaultGsonJson(com.google.gson.Gson gson)

      Constructor
      Parameters:
        `gson` - The `Gson` parser (not null)

  - ### Method Detail

    - #### toJson

          public JsonWriter toJson(Object value)

      Description copied from interface: `Json`
      Serialize given `value` to JSON.
      Specified by:
        `toJson` in interface `Json`
      Parameters:
        `value` - Value to serialize
      Returns:
        a `JsonWriter` from which to obtain the serialized JSON data.

    - #### toJsonArray

          public <T> JsonWriter toJsonArray(Class<T> type,
                                            Collection<T> values)

      Description copied from interface: `Json`
      Serialize given collection of values as a JSON array.
      Specified by:
        `toJsonArray` in interface `Json`
      Type Parameters:
        `T` - Values type
      Parameters:
        `type` - Value type
        `values` - Values collection
      Returns:
        a `JsonWriter` from which to obtain the serialized JSON data.

    - #### fromJson

          public <T> T fromJson(JsonReader reader,
                                Class<T> type)

      Description copied from interface: `Json`
      Deserializes the specified JSON source into an object of the specified type.
      Specified by:
        `fromJson` in interface `Json`
      Type Parameters:
        `T` - desired object type
      Parameters:
        `reader` - JSON data source (not null)
        `type` - the type of the desired object (not null)
      Returns:
        the deserialized object instance

    - #### fromJsonArray

          public <T> List<T> fromJsonArray(JsonReader reader,
                                           Class<T> type)

      Description copied from interface: `Json`
      Deserializes the specified JSON array data source into a `List` of objects of the specified type.
      Specified by:
        `fromJsonArray` in interface `Json`
      Type Parameters:
        `T` - desired object type
      Parameters:
        `reader` - JSON data source (not null)
        `type` - the type of the desired objects (not null)
      Returns:
        the deserialized objects list

    - #### fromJson

          public <P extends com.holonplatform.core.property.Property> com.holonplatform.core.property.PropertyBox fromJson(JsonReader reader,
                                                                                                                           Iterable<P> propertySet)

      Description copied from interface: `Json`
      Deserializes the specified JSON data source into a `PropertyBox`, using given `propertySet` as `PropertyBox` property set.
      Specified by:
        `fromJson` in interface `Json`
      Type Parameters:
        `P` - Actual property type
      Parameters:
        `reader` - JSON data source (not null)
        `propertySet` - Property set to use to build the deserialized `PropertyBox` (not null)
      Returns:
        the deserialized `PropertyBox`

    - #### fromJsonArray

          public <P extends com.holonplatform.core.property.Property> List<com.holonplatform.core.property.PropertyBox> fromJsonArray(JsonReader reader,
                                                                                                                                      Iterable<P> propertySet)

      Description copied from interface: `Json`
      Deserializes the specified JSON array data source into a list of `PropertyBox`, using given `propertySet` as `PropertyBox` property set.
      Specified by:
        `fromJsonArray` in interface `Json`
      Type Parameters:
        `P` - Actual property type
      Parameters:
        `reader` - JSON data source (not null)
        `propertySet` - Property set to use to build the deserialized `PropertyBox`s (not null)
      Returns:
        the deserialized `List` of `PropertyBox`

Copyright © 2019 The Holon Platform. All rights reserved.