Package org.apache.groovy.json.internal
Class JsonParserLax
java.lang.Object
org.apache.groovy.json.internal.BaseJsonParser
org.apache.groovy.json.internal.JsonParserCharArray
org.apache.groovy.json.internal.JsonParserLax
- All Implemented Interfaces:
JsonParser
JSON parser variant that also accepts comments, single quotes, and unquoted strings.
-
Field Summary
Fields inherited from class org.apache.groovy.json.internal.JsonParserCharArray
__currentChar, __index, charArray, FALSE, NULL, TRUEFields inherited from class org.apache.groovy.json.internal.BaseJsonParser
ALPHA_0, ALPHA_1, ALPHA_2, ALPHA_3, ALPHA_4, ALPHA_5, ALPHA_6, ALPHA_7, ALPHA_8, ALPHA_9, bufSize, charset, CLOSED_BRACKET, CLOSED_CURLY, COLON, COMMA, DECIMAL_POINT, DOUBLE_QUOTE, ESCAPE, internedKeysCache, internKeys, LETTER_BIG_E, LETTER_E, MINUS, PLUS -
Constructor Summary
ConstructorsConstructorDescriptionCreates a lax parser with eager value containers and lazy chopping.JsonParserLax(boolean useValues) Creates a lax parser with the supplied value-container mode.JsonParserLax(boolean useValues, boolean chop) Creates a lax parser with explicit chopping behavior.JsonParserLax(boolean useValues, boolean chop, boolean lazyChop) Creates a lax parser with explicit lazy chopping behavior.JsonParserLax(boolean useValues, boolean chop, boolean lazyChop, boolean defaultCheckDates) Creates a lax parser with full overlay configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected final ObjectdecodeFromChars(char[] cs) Parses a character buffer and unwraps top-level container values.protected final ValuedecodeNumberLax(boolean minus) Decodes a number from a JSON value.protected final ObjectDecodes the next value using the parser's lax JSON rules.Methods inherited from class org.apache.groovy.json.internal.JsonParserCharArray
complain, currentChar, decodeFalse, decodeJsonArray, decodeJsonObject, decodeNull, decodeTrue, exceptionDetails, hasCurrent, hasMore, nextChar, parse, skipWhiteSpaceMethods inherited from class org.apache.groovy.json.internal.BaseJsonParser
charDescription, findEndQuote, hasEscapeChar, isDecimalChar, isDelimiter, isDoubleQuote, isEscape, isNumberDigit, parse, parse, parse, parse, parse, parse, parse, parse, setCharset
-
Constructor Details
-
JsonParserLax
public JsonParserLax()Creates a lax parser with eager value containers and lazy chopping. -
JsonParserLax
public JsonParserLax(boolean useValues) Creates a lax parser with the supplied value-container mode.- Parameters:
useValues- whether to use eagerValuecontainers
-
JsonParserLax
public JsonParserLax(boolean useValues, boolean chop) Creates a lax parser with explicit chopping behavior.- Parameters:
useValues- whether to use eagerValuecontainerschop- whether to eagerly copy overlay slices
-
JsonParserLax
public JsonParserLax(boolean useValues, boolean chop, boolean lazyChop) Creates a lax parser with explicit lazy chopping behavior.- Parameters:
useValues- whether to use eagerValuecontainerschop- whether to eagerly copy overlay sliceslazyChop- whether to defer chopping until values are accessed
-
JsonParserLax
public JsonParserLax(boolean useValues, boolean chop, boolean lazyChop, boolean defaultCheckDates) Creates a lax parser with full overlay configuration.- Parameters:
useValues- whether to use eagerValuecontainerschop- whether to eagerly copy overlay sliceslazyChop- whether to defer chopping until values are accesseddefaultCheckDates- whether strings should be tested for supported date formats
-
-
Method Details
-
decodeValue
Decodes the next value using the parser's lax JSON rules.- Overrides:
decodeValuein classJsonParserCharArray- Returns:
- parsed Groovy JSON value or overlay value
-
decodeNumberLax
Decodes a number from a JSON value. If at any point it is determined that the value is not a valid number the value is treated as aString.- Parameters:
minus- indicate whether the number is negative- Returns:
- a number, or
Stringif not a valid number
-
decodeFromChars
Parses a character buffer and unwraps top-level container values.- Overrides:
decodeFromCharsin classJsonParserCharArray- Parameters:
cs- JSON content to parse- Returns:
- parsed Groovy JSON value
-