Package org.apache.groovy.json.internal
Class JsonParserUsingCharacterSource
java.lang.Object
org.apache.groovy.json.internal.BaseJsonParser
org.apache.groovy.json.internal.JsonParserUsingCharacterSource
- All Implemented Interfaces:
JsonParser
Converts an input JSON String into Java objects works with String or char array
as input. Produces an Object which can be any of the basic JSON types mapped
to Java.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static char[]Character buffer for thefalseliteral.protected static final char[]Character buffer for thenullliteral.protected static final char[]Character buffer for thetrueliteral.Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidThrows aJsonExceptionfor the current source location.protected final booleanConsumes thefalseliteral.protected final ListDecodes a JSON array from the current character source position.protected final ObjectDecodes a JSON object from the current character source position.protected final ObjectConsumes thenullliteral.protected final booleanConsumes thetrueliteral.protected StringexceptionDetails(String message) Builds an error message using the current character source state.parse(char[] chars) Parses JSON from a character array.Parses JSON from a reader-backed character source.Methods inherited from class org.apache.groovy.json.internal.BaseJsonParser
charDescription, findEndQuote, hasEscapeChar, isDecimalChar, isDelimiter, isDoubleQuote, isEscape, isNumberDigit, parse, parse, parse, parse, parse, parse, parse, setCharset
-
Field Details
-
NULL
protected static final char[] NULLCharacter buffer for thenullliteral. -
TRUE
protected static final char[] TRUECharacter buffer for thetrueliteral. -
FALSE
protected static char[] FALSECharacter buffer for thefalseliteral.
-
-
Constructor Details
-
JsonParserUsingCharacterSource
public JsonParserUsingCharacterSource()
-
-
Method Details
-
exceptionDetails
Builds an error message using the current character source state.- Parameters:
message- parser-specific message- Returns:
- formatted error details
-
decodeJsonObject
Decodes a JSON object from the current character source position.- Returns:
- parsed object as a
LazyMap
-
complain
Throws aJsonExceptionfor the current source location.- Parameters:
complaint- message describing the parse failure
-
decodeNull
Consumes thenullliteral.- Returns:
null
-
decodeTrue
protected final boolean decodeTrue()Consumes thetrueliteral.- Returns:
true
-
decodeFalse
protected final boolean decodeFalse()Consumes thefalseliteral.- Returns:
false
-
decodeJsonArray
Decodes a JSON array from the current character source position.- Returns:
- parsed array contents
-
parse
Parses JSON from a reader-backed character source.- Specified by:
parsein interfaceJsonParser- Overrides:
parsein classBaseJsonParser- Parameters:
reader- reader supplying JSON content- Returns:
- parsed Groovy JSON value
-
parse
Parses JSON from a character array.- Parameters:
chars- JSON content to parse- Returns:
- parsed Groovy JSON value
-