Package net.sf.saxon.serialize

## Class JSONSerializer

- java.lang.Object
- - net.sf.saxon.event.SequenceReceiver
  - - net.sf.saxon.event.SequenceWriter
    - - net.sf.saxon.serialize.JSONSerializer

- All Implemented Interfaces:
    `javax.xml.transform.Result`, `Receiver`, `ReceiverWithOutputProperties`

      public class JSONSerializer
      extends SequenceWriter
      implements ReceiverWithOutputProperties

  This class implements the JSON serialization method defined in XSLT+XQuery Serialization 3.1.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.event.SequenceReceiver

      `pipelineConfiguration, previousAtomic, systemId`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JSONSerializer​(PipelineConfiguration pipe, JSONEmitter emitter, java.util.Properties outputProperties)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | End of the document.
    `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` | `setPropertySorter​(java.util.Comparator<AtomicValue> sorter)` |
    `void` | `write​(Item item)` | Append an arbitrary item (node or atomic value) to the output

    - ### Methods inherited from class net.sf.saxon.event.SequenceWriter

      `append, characters, comment, endDocument, endElement, getTreeModel, processingInstruction, setTreeModel, setUnparsedEntity, startDocument, startElement, usesTypeAnnotations`

    - ### Methods inherited from class net.sf.saxon.event.SequenceReceiver

      `append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, open, setPipelineConfiguration, setSystemId`

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

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

    - ### Methods inherited from interface net.sf.saxon.event.Receiver

      `append, append, characters, comment, endDocument, endElement, getPipelineConfiguration, handlesAppend, open, processingInstruction, setPipelineConfiguration, setSystemId, setUnparsedEntity, startDocument, startElement, usesTypeAnnotations`

    - ### Methods inherited from interface javax.xml.transform.Result

      `getSystemId`

- - ### Constructor Detail

    - #### JSONSerializer

          public JSONSerializer​(PipelineConfiguration pipe,
                                JSONEmitter emitter,
                                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

    - #### setPropertySorter

          public void setPropertySorter​(java.util.Comparator<AtomicValue> sorter)

    - #### getOutputProperties

          public java.util.Properties getOutputProperties()

      Get the output properties
      Specified by:
        `getOutputProperties` in interface `ReceiverWithOutputProperties`
      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

    - #### write

          public void write​(Item item)
                     throws XPathException

      Append an arbitrary item (node or atomic value) to the output
      Specified by:
        `write` in class `SequenceWriter`
      Parameters:
        `item` - the item to be appended
      Throws:
        `XPathException` - if the operation fails

    - #### close

          public void close()
                     throws XPathException

      End of the document.
      Specified by:
        `close` in interface `Receiver`
      Overrides:
        `close` in class `SequenceWriter`
      Throws:
        `XPathException` - if an error occurs