com.holonplatform.json

## Interface JsonWriter

-     public interface JsonWriter

  Represents a JSON serialization result, providing methods to obtain the JSON data in different formats.
  Since:
    5.1.0
  See Also:
    `Json`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default 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.
    `default void` | `write(OutputStream stream)` Write the JSON data to given `OutputStream`, using the UTF-8 charset for encoding.
    `void` | `write(OutputStream stream, Charset charset)` Write the JSON data to given `OutputStream`, using the given `Charset` for encoding.
    `default void` | `write(OutputStream stream, String charsetName)` Write the JSON data to given `OutputStream`, using the given charset name for encoding.

- - ### Method Detail

    - #### asString

          String asString()

      Get the JSON data as a `String`.
      Returns:
        the JSON data as a String (may be null)
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

    - #### asBytes

          byte[] asBytes()

      Get the JSON data as a byte array.

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

      Returns:
        the JSON data as a byte array (may be null)
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

    - #### write

          void write(Appendable writer)

      Write the JSON data to given `Appendable` writer.
      Parameters:
        `writer` - the writer into which to write the JSON data (not null)
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

    - #### write

          default void write(OutputStream stream)

      Write the JSON data to given `OutputStream`, using the UTF-8 charset for encoding.
      Parameters:
        `stream` - the stream into which to write the JSON data (not null)
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

    - #### write

          default void write(OutputStream stream,
                             String charsetName)

      Write the JSON data to given `OutputStream`, using the given charset name for encoding.
      Parameters:
        `stream` - the stream into which to write the JSON data (not null)
        `charsetName` - charset name to use for encoding
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

    - #### write

          void write(OutputStream stream,
                     Charset charset)

      Write the JSON data to given `OutputStream`, using the given `Charset` for encoding.
      Parameters:
        `stream` - the stream into which to write the JSON data (not null)
        `charset` - charset to use for encoding
      Throws:
        `Json.JsonWriteException` - If a JSON serialization error occured

Copyright © 2019 The Holon Platform. All rights reserved.