org.infinispan.schematic.internal.document

## Interface JsonWriter

- All Known Implementing Classes:
    CompactJsonWriter, PrettyJsonWriter

      public interface JsonWriter

  A component that writes modified JSON representations from the in-memory `Document` representation.

  The modified JSON format is nearly identical to the JSON serialization used by MongoDB. All standard JSON values are written as expected, but the types unique to BSON are written as follows:

  BSON Type | Class | Format | Example
  --- | --- | --- | ---
  Symbol | `Symbol` | "value" | "The quick brown fox"
  Regular Expression | `Pattern` | { "$regex" : "pattern", "$options" : "flags" } | { "$regex" : "[CH]at\sin", "$options" : "im" }
  Date | `Date` | { "$date" : "yyyy-MM-ddTHH:mm:ssZ" } | { "$date" : "2011-06-11T08:44:25Z" }
  Timestamp | `Timestamp` | { "$ts" : timeValue, "$inc" : incValue } | "\/TS("2011-06-11T08:44:25Z")\/"
  ObjectId | `ObjectId` | { "$oid" : "12bytesOfIdInBase16" } | { "$oid" : "0000012c0000c8000900000f" }
  Binary | `Binary` | { "$type" : typeAsInt, "$base64" : "bytesInBase64" }" | { "$type" : 0, "$base64" : "TWFuIGlzIGRpc3R" }"
  UUID | `UUID` | { "$uuid" : "string-form-of-uuid" } | { "$uuid" : "09e0e949-bba4-459c-bb1d-9352e5ee8958" }
  Code | `Code` | { "$code" : "code" } | { "$code" : "244-I2" }
  CodeWithScope | `CodeWithScope` | { "$code" : "code", "$scope" : scope document } | { "$code" : "244-I2", "$scope" : { "name" : "Joe" } }
  MinKey | `MinKey` | "MinKey" | "MinKey"
  MaxKey | `MaxKey` | "MaxKey" | "MaxKey"
  Null value |  | null | null

  Since:
    5.1

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `write(Object object)` Write and return the modified JSON representation of the supplied in-memory `Document`.
    `void` | `write(Object object, OutputStream stream)` Write to the supplied stream the modified JSON representation of the supplied in-memory `Document`.
    `void` | `write(Object object, StringBuilder builder)` Write to the supplied string builder the modified JSON representation of the supplied in-memory `Document` .
    `void` | `write(Object object, Writer writer)` Write to the supplied writer the modified JSON representation of the supplied in-memory `Document`.

- - ### Method Detail

    - #### write

          void write(Object object,
                   OutputStream stream)
                     throws IOException

      Write to the supplied stream the modified JSON representation of the supplied in-memory `Document`.
      Parameters:
        `object` - the BSON object or BSON value; may not be null
        `stream` - the output stream; may not be null
      Throws:
        `IOException` - if there was a problem reading from the stream

    - #### write

          void write(Object object,
                   Writer writer)
                     throws IOException

      Write to the supplied writer the modified JSON representation of the supplied in-memory `Document`.
      Parameters:
        `object` - the BSON object or BSON value; may not be null
        `writer` - the writer; may not be null
      Throws:
        `IOException` - if there was a problem reading from the stream

    - #### write

          void write(Object object,
                   StringBuilder builder)

      Write to the supplied string builder the modified JSON representation of the supplied in-memory `Document` .
      Parameters:
        `object` - the BSON object or BSON value; may not be null
        `builder` - the string builder; may not be null

    - #### write

          String write(Object object)

      Write and return the modified JSON representation of the supplied in-memory `Document`.
      Parameters:
        `object` - the BSON object or BSON value; may not be null
      Returns:
        the JSON string representation; never null

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.