Package net.sf.saxon.ma.json
Class JsonParser
java.lang.Object
net.sf.saxon.ma.json.JsonParser
Parser for JSON, which notifies parsing events to a JsonHandler
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetFlags(Map<String, GroundedValue> options, boolean allowValidate, boolean isSchemaAware) Extract the requested JSON parsing options as a set of flags in a bit-significant integerobtainShape(List<UnicodeString> keyList) Given a list of keys present in a JSON map/object, find aShapethat can be used to create a shaped map for these keys.voidparse(IntIterator input, int flags, JsonHandler handler, XPathContext context) Parse the JSON string according to supplied optionsvoidsetNumberParser(Map<String, GroundedValue> options) static StringshowToken(JsonParser.JsonToken token, UnicodeString currentTokenValue)
-
Field Details
-
ESCAPE
public static final int ESCAPE- See Also:
-
ALLOW_ANY_TOP_LEVEL
public static final int ALLOW_ANY_TOP_LEVEL- See Also:
-
LIBERAL
public static final int LIBERAL- See Also:
-
VALIDATE
public static final int VALIDATE- See Also:
-
DUPLICATES_RETAINED
public static final int DUPLICATES_RETAINED- See Also:
-
DUPLICATES_LAST
public static final int DUPLICATES_LAST- See Also:
-
DUPLICATES_FIRST
public static final int DUPLICATES_FIRST- See Also:
-
DUPLICATES_REJECTED
public static final int DUPLICATES_REJECTED- See Also:
-
NUMERIC_FORMAT_RETAINED
public static final int NUMERIC_FORMAT_RETAINED- See Also:
-
ORDER_RETAINED
public static final int ORDER_RETAINED- See Also:
-
DUPLICATES_SPECIFIED
public static final int DUPLICATES_SPECIFIED- See Also:
-
NESTING_LIMIT
public static final int NESTING_LIMIT- See Also:
-
-
Constructor Details
-
JsonParser
public JsonParser()Create a JSON parser
-
-
Method Details
-
parse
public void parse(IntIterator input, int flags, JsonHandler handler, XPathContext context) throws XPathException Parse the JSON string according to supplied options- Parameters:
input- JSON input string, supplied as an iterator over Unicode codepointsflags- options for the conversion as a map of xs:string : value pairshandler- event handler to which parsing events are notifiedcontext- the XPath evaluation context- Throws:
XPathException- if the syntax of the input is incorrect
-
getFlags
public static int getFlags(Map<String, GroundedValue> options, boolean allowValidate, boolean isSchemaAware) throws XPathExceptionExtract the requested JSON parsing options as a set of flags in a bit-significant integer- Parameters:
options- the supplied options mapallowValidate- true if the validate option is permittedisSchemaAware- 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
-
showToken
-
setNumberParser
- Throws:
XPathException
-
obtainShape
Given a list of keys present in a JSON map/object, find aShapethat can be used to create a shaped map for these keys. The thinking is that in JSON, many maps/objects will often have the same set of keys and this can be used to optimize storage and retrieval- Parameters:
keyList- the list of keys- Returns:
- a Shape corresponding to this list of keys. Shapes are pooled at the level of the JSON parser, so two records in the same JSON document with the same set of keys will share the same Shape object.
-