Class JsonParser


  • public class JsonParser
    extends java.lang.Object
    Parser for JSON, which notifies parsing events to a JsonHandler
    • Constructor Detail

      • JsonParser

        public JsonParser()
        Create a JSON parser
    • Method Detail

      • parse

        public void parse​(java.lang.String input,
                          int flags,
                          JsonHandler handler,
                          XPathContext context)
                   throws XPathException
        Parse the JSON string according to supplied options
        Parameters:
        input - JSON input string
        flags - options for the conversion as a map of xs:string : value pairs
        handler - event handler to which parsing events are notified
        context - XPath evaluation context
        Throws:
        XPathException - if the syntax of the input is incorrect
      • getFlags

        public static int getFlags​(java.util.Map<java.lang.String,​Sequence> options,
                                   boolean allowValidate,
                                   boolean isSchemaAware)
                            throws XPathException
        Extract the requested JSON parsing options as a set of flags in a bit-significant integer
        Parameters:
        options - the supplied options map
        allowValidate - true if the validate option is permitted
        isSchemaAware - true if the processor is schema-aware (only relevant when allowValidate=true)
        Returns:
        the options as a sef of flags
        Throws:
        XPathException - if any options are invalid
      • unescape

        public static java.lang.String unescape​(java.lang.String literal,
                                                int flags,
                                                java.lang.String errorCode,
                                                int lineNumber)
                                         throws XPathException
        Unescape a JSON string literal
        Parameters:
        literal - the string literal to be processed
        flags - parsing options
        errorCode - Error code
        lineNumber - the line number
        Returns:
        the result of parsing and conversion to XDM
        Throws:
        XPathException - if a dynamic error occurs (such as invalid JSON input)
      • showToken

        public static java.lang.String showToken​(JsonParser.JsonToken token,
                                                 java.lang.String currentTokenValue)