Class JSONSerializer

All Implemented Interfaces:
Result, Receiver, ReceiverWithOutputProperties

public class JSONSerializer extends SequenceWriter implements ReceiverWithOutputProperties
This class implements the JSON serialization method defined in XSLT+XQuery Serialization 3.1.
  • Constructor Details

  • Method Details

    • setOutputProperties

      public void setOutputProperties(Properties details)
      Set output properties
      Parameters:
      details - the output serialization properties
    • setPropertySorter

      public void setPropertySorter(Comparator<AtomicValue> sorter)
    • setCanonicalPropertySorter

      public void setCanonicalPropertySorter()
      Set property sorting as required by canonical JSON: this sorts by UTF-16 code units, which happens to be the same as Java's so-called "natural" order for strings
    • getOutputProperties

      public Properties getOutputProperties()
      Get the output properties
      Specified by:
      getOutputProperties in interface ReceiverWithOutputProperties
      Returns:
      the properties that were set using setOutputProperties
    • setNormalizationForm

      public void setNormalizationForm(Normalizer.Form form)
      Set the Unicode normalizer to be used for normalizing strings.
      Parameters:
      form - the normalization form 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