Class ParseJsonFn

  • All Implemented Interfaces:
    Callable, Function, GroundedValue, Item, Sequence

    public class ParseJsonFn
    extends JsonToXMLFn
    Implements the parse-json function, as defined in XPath 3.1 The parsing code, and the handling of options is shared with the json-to-xml function.
    • Constructor Detail

      • ParseJsonFn

        public ParseJsonFn()
    • Method Detail

      • eval

        protected Item eval​(java.lang.String input,
                            MapItem options,
                            XPathContext context)
                     throws XPathException
        Parse the JSON string according to supplied options
        Overrides:
        eval in class JsonToXMLFn
        Parameters:
        input - JSON input string
        options - options for the conversion as a map of xs:string : value pairs
        context - XPath evaluation context
        Returns:
        the result of the parsing, typically a map or array
        Throws:
        XPathException - if the syntax of the input is incorrect
      • parse

        public static Item parse​(java.lang.String input,
                                 java.util.Map<java.lang.String,​Sequence> options,
                                 XPathContext context)
                          throws XPathException
        Parse the JSON string according to supplied options
        Parameters:
        input - JSON input string
        options - options for the conversion as a map of xs:string : value pairs
        context - XPath evaluation context
        Returns:
        the result of the parsing, as an item (null in the case where the JSON input is "null")
        Throws:
        XPathException - if the syntax of the input is incorrect