public class JSONParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
JSONParser.ParseException |
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER |
static int |
ALLOW_COMMENTS
Flags to control parsing behavior
|
static int |
ALLOW_EXTRA_COMMAS
ALLOW_EXTRA_COMMAS causes any nunber of extra commas in arrays and objects to be ignored
Note that a trailing comma in [] would be [,] (hence calling the feature "trailing" commas
isn't really correct.
|
static int |
ALLOW_SINGLE_QUOTES |
static int |
ALLOW_UNQUOTED_KEYS |
static int |
ALLOW_UNQUOTED_STRING_VALUES |
static int |
ARRAY_END
Event indicating the end of a JSON array
|
static int |
ARRAY_START
Event indicating the start of a JSON array
|
static int |
BIGNUMBER
Event indicating a JSON number value that was not produced by toString of any
Java primitive numerics such as Double or Long.
|
private boolean |
bool |
static int |
BOOLEAN
Event indicating a JSON boolean
|
(package private) char[] |
buf |
private static CharArr |
devNull |
private static byte |
DID_ARRELEM |
private static byte |
DID_ARRSTART |
private static byte |
DID_MEMNAME |
private static byte |
DID_MEMVAL |
private static byte |
DID_OBJSTART |
(package private) int |
end |
(package private) boolean |
eof |
static int |
EOF
Event indicating the end of input has been reached
|
(package private) int |
event |
(package private) int |
flags |
static int |
FLAGS_DEFAULT |
static int |
FLAGS_STRICT |
(package private) long |
gpos |
private static int |
HAS_EXPONENT |
private static int |
HAS_FRACTION |
(package private) java.io.Reader |
in |
static int |
LONG
Event indicating a JSON number value which fits into a signed 64 bit integer
|
private long |
lval |
private int |
nstate |
static int |
NULL
Event indicating a JSON null
|
static int |
NUMBER
Event indicating a JSON number value which has a fractional part or an exponent
and with string length <= 23 chars not including sign.
|
static int |
OBJECT_END
Event indicating the end of a JSON object
|
static int |
OBJECT_START
Event indicating the start of a JSON object
|
private CharArr |
out |
private int |
ptr |
private byte[] |
stack |
(package private) int |
start |
private byte |
state |
static int |
STRING
Event indicating a JSON string value, including member names of objects
|
(package private) int |
stringTerm |
private CharArr |
tmp |
private int |
valstate |
private static long |
WS_MASK |
Constructor and Description |
---|
JSONParser(char[] data,
int start,
int end) |
JSONParser(java.io.Reader in) |
JSONParser(java.io.Reader in,
char[] buffer) |
JSONParser(java.lang.String data) |
JSONParser(java.lang.String data,
int start,
int end) |
Modifier and Type | Method and Description |
---|---|
private void |
continueNumber(CharArr arr) |
protected JSONParser.ParseException |
err(java.lang.String msg) |
private java.lang.String |
errEscape(int a,
int b) |
protected void |
fill() |
boolean |
getBoolean()
Reads a boolean value
|
protected int |
getChar() |
private int |
getCharExpected(int expected) |
protected int |
getCharNWS() |
protected int |
getCharNWS(int ch) |
private java.lang.String |
getContext() |
double |
getDouble()
Reads a number from the input stream and parses it as a double
|
static java.lang.String |
getEventString(int e) |
int |
getFlags() |
int |
getLevel() |
long |
getLong()
Reads a number from the input stream and parses it as a long, only if
the value will in fact fit into a signed 64 bit integer.
|
private void |
getMore() |
protected void |
getNewlineComment() |
void |
getNull()
Reads a null value
|
CharArr |
getNumberChars()
Returns the characters of a JSON numeric value.
|
void |
getNumberChars(CharArr output)
Reads a JSON numeric value into the output.
|
long |
getPosition() |
protected void |
getSlashComment() |
java.lang.String |
getString()
Returns the JSON string value, decoding any escaped characters.
|
void |
getString(CharArr output)
Reads a JSON string into the output, decoding any escaped characters.
|
CharArr |
getStringChars()
Returns the characters of a JSON string value, decoding any escaped characters.
|
private void |
goTo(int what) |
private void |
handleNonDoubleQuoteString(int ch,
boolean isName) |
private int |
hexval(int hexdig) |
private static boolean |
isUnquotedStringChar(int ch) |
private static boolean |
isUnquotedStringStart(int ch) |
protected static boolean |
isWhitespace(int ch)
Returns true if the given character is considered to be whitespace.
|
int |
lastEvent() |
private boolean |
matchBareWord(char[] arr) |
private int |
next(int ch)
alternate implementation
// middle is the pointer to the middle of a buffer to start scanning for a non-string
// character ('"' or "/").
|
int |
nextEvent()
Returns the next event encountered in the JSON stream, one of
STRING
LONG
NUMBER
BIGNUMBER
BOOLEAN
NULL
OBJECT_START
OBJECT_END
OBJECT_END
ARRAY_START
ARRAY_END
EOF
|
private void |
pop() |
private void |
push() |
private char |
readEscapedChar() |
private int |
readExp(CharArr arr,
int lim) |
private int |
readExpDigits(CharArr arr,
int lim) |
private int |
readFrac(CharArr arr,
int lim) |
private long |
readNumber(int firstChar,
boolean isNeg)
Returns the long read...
|
private void |
readStringBare(CharArr arr) |
private CharArr |
readStringChars() |
private void |
readStringChars2(CharArr arr,
int middle) |
int |
setFlags(int flags) |
java.lang.String |
toString() |
boolean |
wasKey() |
public static final int STRING
public static final int LONG
public static final int NUMBER
public static final int BIGNUMBER
public static final int BOOLEAN
public static final int NULL
public static final int OBJECT_START
public static final int OBJECT_END
public static final int ARRAY_START
public static final int ARRAY_END
public static final int EOF
public static final int ALLOW_COMMENTS
public static final int ALLOW_SINGLE_QUOTES
public static final int ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
public static final int ALLOW_UNQUOTED_KEYS
public static final int ALLOW_UNQUOTED_STRING_VALUES
public static final int ALLOW_EXTRA_COMMAS
public static final int FLAGS_STRICT
public static final int FLAGS_DEFAULT
private static final CharArr devNull
int flags
final char[] buf
int start
int end
final java.io.Reader in
boolean eof
long gpos
int event
int stringTerm
private final CharArr out
private byte[] stack
private int ptr
private byte state
private static final byte DID_OBJSTART
private static final byte DID_ARRSTART
private static final byte DID_ARRELEM
private static final byte DID_MEMNAME
private static final byte DID_MEMVAL
private int valstate
private static final long WS_MASK
private boolean bool
private long lval
private int nstate
private static final int HAS_FRACTION
private static final int HAS_EXPONENT
private final CharArr tmp
public JSONParser(java.io.Reader in)
public JSONParser(java.io.Reader in, char[] buffer)
public JSONParser(char[] data, int start, int end)
public JSONParser(java.lang.String data)
public JSONParser(java.lang.String data, int start, int end)
public static java.lang.String getEventString(int e)
public int getFlags()
public int setFlags(int flags)
private final void push()
private final void pop()
protected void fill() throws java.io.IOException
java.io.IOException
private void getMore() throws java.io.IOException
java.io.IOException
protected int getChar() throws java.io.IOException
java.io.IOException
protected static final boolean isWhitespace(int ch)
protected int getCharNWS() throws java.io.IOException
java.io.IOException
protected int getCharNWS(int ch) throws java.io.IOException
java.io.IOException
private int getCharExpected(int expected) throws java.io.IOException
java.io.IOException
protected void getNewlineComment() throws java.io.IOException
java.io.IOException
protected void getSlashComment() throws java.io.IOException
java.io.IOException
private boolean matchBareWord(char[] arr) throws java.io.IOException
java.io.IOException
protected JSONParser.ParseException err(java.lang.String msg)
private java.lang.String getContext()
private java.lang.String errEscape(int a, int b)
private long readNumber(int firstChar, boolean isNeg) throws java.io.IOException
java.io.IOException
private int readFrac(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private int readExp(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private int readExpDigits(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private void continueNumber(CharArr arr) throws java.io.IOException
java.io.IOException
private int hexval(int hexdig)
private char readEscapedChar() throws java.io.IOException
java.io.IOException
private CharArr readStringChars() throws java.io.IOException
java.io.IOException
private void readStringChars2(CharArr arr, int middle) throws java.io.IOException
java.io.IOException
private void readStringBare(CharArr arr) throws java.io.IOException
java.io.IOException
private void handleNonDoubleQuoteString(int ch, boolean isName) throws java.io.IOException
java.io.IOException
private static boolean isUnquotedStringStart(int ch)
private static boolean isUnquotedStringChar(int ch)
private int next(int ch) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public int nextEvent() throws java.io.IOException
java.io.IOException
public int lastEvent()
public boolean wasKey()
private void goTo(int what) throws java.io.IOException
java.io.IOException
public java.lang.String getString() throws java.io.IOException
java.io.IOException
public CharArr getStringChars() throws java.io.IOException
CharArr
should *not* be
modified as it may be shared with the input buffer.
The returned CharArr
will only be valid up until
the next JSONParser method is called. Any required data should be
read before that point.java.io.IOException
public void getString(CharArr output) throws java.io.IOException
java.io.IOException
public long getLong() throws java.io.IOException
java.io.IOException
public double getDouble() throws java.io.IOException
java.io.IOException
public CharArr getNumberChars() throws java.io.IOException
CharArr
should *not* be
modified as it may be shared with the input buffer.
The returned CharArr
will only be valid up until
the next JSONParser method is called. Any required data should be
read before that point.java.io.IOException
public void getNumberChars(CharArr output) throws java.io.IOException
java.io.IOException
public boolean getBoolean() throws java.io.IOException
java.io.IOException
public void getNull() throws java.io.IOException
java.io.IOException
public int getLevel()
public long getPosition()