com.holonplatform.json.gson.internal

## Class GsonJsonWriter

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

- All Implemented Interfaces:
    JsonWriter

      public class GsonJsonWriter
      extends Object
      implements JsonWriter

  Gson implementation of the `JsonWriter`.
  Since:
    5.1.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GsonJsonWriter(com.google.gson.Gson gson, Object value)` Default constructor.
    `GsonJsonWriter(com.google.gson.Gson gson, Object value, Type typeOfSrc)` Constructor with type parameter.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `asBytes()` Get the JSON data as a byte array.
    `String` | `asString()` Get the JSON data as a `String`.
    `void` | `write(Appendable writer)` Write the JSON data to given `Appendable` writer.
    `void` | `write(OutputStream stream, Charset charset)` Write the JSON data to given `OutputStream`, using the given `Charset` for encoding.

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

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

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

      `write, write`

- - ### Constructor Detail

    - #### GsonJsonWriter

          public GsonJsonWriter(com.google.gson.Gson gson,
                                Object value)

      Default constructor.
      Parameters:
        `gson` - Gson istance (not null)
        `value` - Value to serialize

    - #### GsonJsonWriter

          public GsonJsonWriter(com.google.gson.Gson gson,
                                Object value,
                                Type typeOfSrc)

      Constructor with type parameter.
      Parameters:
        `gson` - Gson istance (not null)
        `value` - Value to serialize
        `typeOfSrc` - Type of the object to serialize

  - ### Method Detail

    - #### asString

          public String asString()

      Description copied from interface: `JsonWriter`
      Get the JSON data as a `String`.
      Specified by:
        `asString` in interface `JsonWriter`
      Returns:
        the JSON data as a String (may be null)

    - #### asBytes

          public byte[] asBytes()

      Description copied from interface: `JsonWriter`
      Get the JSON data as a byte array.

      By default, the UTF-8 charset is used for encoding.

      Specified by:
        `asBytes` in interface `JsonWriter`
      Returns:
        the JSON data as a byte array (may be null)

    - #### write

          public void write(Appendable writer)

      Description copied from interface: `JsonWriter`
      Write the JSON data to given `Appendable` writer.
      Specified by:
        `write` in interface `JsonWriter`
      Parameters:
        `writer` - the writer into which to write the JSON data (not null)

    - #### write

          public void write(OutputStream stream,
                            Charset charset)

      Description copied from interface: `JsonWriter`
      Write the JSON data to given `OutputStream`, using the given `Charset` for encoding.
      Specified by:
        `write` in interface `JsonWriter`
      Parameters:
        `stream` - the stream into which to write the JSON data (not null)
        `charset` - charset to use for encoding

Copyright © 2019 The Holon Platform. All rights reserved.