Class ParseJsonFn

All Implemented Interfaces:
Callable, FunctionItem, 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.
  • Field Details

  • Constructor Details

    • ParseJsonFn

      public ParseJsonFn()
  • Method Details

    • eval

      protected Item eval(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(String input, Map<String,GroundedValue> 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