Package net.sf.saxon.serialize

## Class JSONEmitter

- java.lang.Object
- - net.sf.saxon.serialize.JSONEmitter

-     public class JSONEmitter
      extends java.lang.Object

  This class implements the back-end text generation of the JSON serialization method. It takes as input a sequence of event-based calls such as startArray, endArray, startMap, endMap, and generates the lexical JSON output.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JSONEmitter​(PipelineConfiguration pipe, javax.xml.transform.stream.StreamResult result, java.util.Properties outputProperties)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | End of the document.
    `void` | `endArray()` | Output the end of an array
    `void` | `endMap()` |
    `java.util.Properties` | `getOutputProperties()` | Get the output properties
    `void` | `setCharacterMap​(CharacterMap map)` | Set the CharacterMap to be used, if any
    `void` | `setNormalizer​(Normalizer normalizer)` | Set the Unicode normalizer to be used for normalizing strings.
    `void` | `setOutputProperties​(java.util.Properties details)` | Set output properties
    `void` | `startArray​(boolean oneLiner)` | Output the start of an array.
    `void` | `startMap​(boolean oneLiner)` | Output the start of an map.
    `void` | `writeAtomicValue​(AtomicValue item)` | Append a singleton value (number, string, or boolean) to the output
    `void` | `writeKey​(java.lang.String key)` | Output the key for an entry in a map.

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

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

- - ### Constructor Detail

    - #### JSONEmitter

          public JSONEmitter​(PipelineConfiguration pipe,
                             javax.xml.transform.stream.StreamResult result,
                             java.util.Properties outputProperties)
                      throws XPathException

      Throws:
        `XPathException`

  - ### Method Detail

    - #### setOutputProperties

          public void setOutputProperties​(java.util.Properties details)

      Set output properties
      Parameters:
        `details` - the output serialization properties

    - #### getOutputProperties

          public java.util.Properties getOutputProperties()

      Get the output properties
      Returns:
        the properties that were set using setOutputProperties

    - #### setNormalizer

          public void setNormalizer​(Normalizer normalizer)

      Set the Unicode normalizer to be used for normalizing strings.
      Parameters:
        `normalizer` - the normalizer to be used

    - #### setCharacterMap

          public void setCharacterMap​(CharacterMap map)

      Set the CharacterMap to be used, if any
      Parameters:
        `map` - the character map

    - #### writeKey

          public void writeKey​(java.lang.String key)
                        throws XPathException

      Output the key for an entry in a map. The corresponding value must be supplied in the following call.
      Parameters:
        `key` - the value of the key, without any escaping of special characters
      Throws:
        `XPathException` - if any error occurs

    - #### writeAtomicValue

          public void writeAtomicValue​(AtomicValue item)
                                throws XPathException

      Append a singleton value (number, string, or boolean) to the output
      Parameters:
        `item` - the atomic value to be appended, or null to append "null"
      Throws:
        `XPathException` - if the operation fails

    - #### startArray

          public void startArray​(boolean oneLiner)
                          throws XPathException

      Output the start of an array. This call must be followed by the members of the array, followed by a call on `endArray()`.
      Parameters:
        `oneLiner` - True if the caller thinks the value should be output without extra newlines after the open bracket or before the close bracket, even when indenting is on.
      Throws:
        `XPathException` - if any failure occurs

    - #### endArray

          public void endArray()
                        throws XPathException

      Output the end of an array
      Throws:
        `XPathException` - if any failure occurs

    - #### startMap

          public void startMap​(boolean oneLiner)
                        throws XPathException

      Output the start of an map. This call must be followed by the entries in the map (each starting with a call on `writeKey(String)`, followed by a call on `endMap()`.
      Parameters:
        `oneLiner` - True if the caller thinks the value should be output without extra newlines after the open bracket or before the close bracket, even when indenting is on.
      Throws:
        `XPathException` - if any failure occurs

    - #### endMap

          public void endMap()
                      throws XPathException

      Throws:
        `XPathException`

    - #### close

          public void close()
                     throws XPathException

      End of the document.
      Throws:
        `XPathException`