Package net.sf.saxon.ma.json

## Class JsonHandlerMap

- java.lang.Object
- - net.sf.saxon.ma.json.JsonHandler
  - - net.sf.saxon.ma.json.JsonHandlerMap

-     public class JsonHandlerMap
      extends JsonHandler

  Event handler for the JSON parser which constructs a structure of maps and arrays representing the content of the JSON text.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected java.util.Stack<java.lang.String>` | `keys` |

    - ### Fields inherited from class net.sf.saxon.ma.json.JsonHandler

      `charChecker, escape`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JsonHandlerMap​(XPathContext context, int flags)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `endArray()` | Close the current array
    `void` | `endMap()` | Close the current object/map
    `Sequence` | `getResult()` |
    `boolean` | `setKey​(java.lang.String unEscaped, java.lang.String reEscaped)` | Set the key to be written for the next entry in an object/map
    `void` | `startArray()` | Open a new array
    `void` | `startMap()` | Start a new object/map
    `void` | `writeBoolean​(boolean value)` | Write a boolean value
    `void` | `writeNull()` | Write a null value
    `void` | `writeNumeric​(java.lang.String asString, double asDouble)` | Write a numeric value
    `void` | `writeString​(java.lang.String val)` | Write a string value

    - ### Methods inherited from class net.sf.saxon.ma.json.JsonHandler

      `getContext, handleInvalidCharacters, markAsEscaped, reEscape, setContext, setFallbackFunction`

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

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

- - ### Field Detail

    - #### keys

          protected java.util.Stack<java.lang.String> keys

  - ### Constructor Detail

    - #### JsonHandlerMap

          public JsonHandlerMap​(XPathContext context,
                                int flags)

  - ### Method Detail

    - #### getResult

          public Sequence getResult()

      Overrides:
        `getResult` in class `JsonHandler`

    - #### setKey

          public boolean setKey​(java.lang.String unEscaped,
                                java.lang.String reEscaped)

      Set the key to be written for the next entry in an object/map
      Overrides:
        `setKey` in class `JsonHandler`
      Parameters:
        `unEscaped` - the key for the entry (null implies no key) in unescaped form (backslashes, if present, do not signal an escape sequence)
        `reEscaped` - the key for the entry (null implies no key) in reescaped form. In this form special characters are represented as backslash-escaped sequences if the escape option is yes; if escape=no, the reEscaped form is the same as the unEscaped form.
      Returns:
        true if the key is already present in the map, false if it is not

    - #### startArray

          public void startArray()

      Open a new array
      Overrides:
        `startArray` in class `JsonHandler`

    - #### endArray

          public void endArray()

      Close the current array
      Overrides:
        `endArray` in class `JsonHandler`

    - #### startMap

          public void startMap()

      Start a new object/map
      Overrides:
        `startMap` in class `JsonHandler`

    - #### endMap

          public void endMap()

      Close the current object/map
      Overrides:
        `endMap` in class `JsonHandler`

    - #### writeNumeric

          public void writeNumeric​(java.lang.String asString,
                                   double asDouble)

      Write a numeric value
      Overrides:
        `writeNumeric` in class `JsonHandler`
      Parameters:
        `asString` - the string representation of the value
        `asDouble` - the double representation of the value

    - #### writeString

          public void writeString​(java.lang.String val)
                           throws XPathException

      Write a string value
      Overrides:
        `writeString` in class `JsonHandler`
      Parameters:
        `val` - The string to be written (which may or may not contain JSON escape sequences, according to the options that were set)
      Throws:
        `XPathException` - if a dynamic error occurs

    - #### writeBoolean

          public void writeBoolean​(boolean value)

      Write a boolean value
      Overrides:
        `writeBoolean` in class `JsonHandler`
      Parameters:
        `value` - the boolean value to be written

    - #### writeNull

          public void writeNull()

      Write a null value
      Overrides:
        `writeNull` in class `JsonHandler`