public class JSONParser extends 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 number of extra commas in arrays and objects to be ignored
Note that a trailing comma in [] would be [,] (hence calling the feature "trailing" commas
is either limiting or misleading.
|
static int |
ALLOW_MISSING_COLON_COMMA_BEFORE_OBJECT |
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.
|
static int |
BOOLEAN
Event indicating a JSON boolean
|
protected char[] |
buf |
protected int |
end |
protected boolean |
eof |
static int |
EOF
Event indicating the end of input has been reached
|
protected int |
event |
protected int |
flags |
static int |
FLAGS_DEFAULT |
static int |
FLAGS_STRICT |
protected long |
gpos |
protected Reader |
in |
static int |
LONG
Event indicating a JSON number value which fits into a signed 64 bit integer
|
protected boolean |
missingOpeningBrace |
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
|
static int |
OPTIONAL_OUTER_BRACES |
protected int |
start |
static int |
STRING
Event indicating a JSON string value, including member names of objects
|
protected int |
stringTerm |
Constructor and Description |
---|
JSONParser(char[] data,
int start,
int end) |
JSONParser(Reader in) |
JSONParser(Reader in,
char[] buffer) |
JSONParser(String data) |
JSONParser(String data,
int start,
int end) |
Modifier and Type | Method and Description |
---|---|
protected JSONParser.ParseException |
err(String msg) |
protected void |
fill() |
boolean |
getBoolean()
Reads a boolean value
|
protected int |
getChar() |
protected int |
getCharExpected(int expected) |
protected int |
getCharNWS() |
protected int |
getCharNWS(int ch) |
double |
getDouble()
Reads a number from the input stream and parses it as a double
|
static 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.
|
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() |
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.
|
protected void |
handleNonDoubleQuoteString(int ch,
boolean isName) |
protected static boolean |
isWhitespace(int ch)
Returns true if the given character is considered to be whitespace.
|
int |
lastEvent() |
protected boolean |
matchBareWord(char[] arr) |
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
|
int |
setFlags(int flags) |
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 ALLOW_MISSING_COLON_COMMA_BEFORE_OBJECT
public static final int OPTIONAL_OUTER_BRACES
public static final int FLAGS_STRICT
public static final int FLAGS_DEFAULT
protected int flags
protected final char[] buf
protected int start
protected int end
protected final Reader in
protected boolean eof
protected long gpos
protected int event
protected int stringTerm
protected boolean missingOpeningBrace
public JSONParser(Reader in)
public JSONParser(Reader in, char[] buffer)
public JSONParser(char[] data, int start, int end)
public JSONParser(String data)
public JSONParser(String data, int start, int end)
public static String getEventString(int e)
public int getFlags()
public int setFlags(int flags)
protected void fill() throws IOException
IOException
protected int getChar() throws IOException
IOException
protected static final boolean isWhitespace(int ch)
protected int getCharNWS() throws IOException
IOException
protected int getCharNWS(int ch) throws IOException
IOException
protected int getCharExpected(int expected) throws IOException
IOException
protected void getNewlineComment() throws IOException
IOException
protected void getSlashComment() throws IOException
IOException
protected boolean matchBareWord(char[] arr) throws IOException
IOException
protected JSONParser.ParseException err(String msg)
protected void handleNonDoubleQuoteString(int ch, boolean isName) throws IOException
IOException
public int nextEvent() throws IOException
IOException
public int lastEvent()
public boolean wasKey()
public String getString() throws IOException
IOException
public CharArr getStringChars() throws 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.IOException
public void getString(CharArr output) throws IOException
IOException
public long getLong() throws IOException
IOException
public double getDouble() throws IOException
IOException
public CharArr getNumberChars() throws IOException
The underlying buffer of the returned 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.
IOException
public void getNumberChars(CharArr output) throws IOException
IOException
public boolean getBoolean() throws IOException
IOException
public void getNull() throws IOException
IOException
public int getLevel()
public long getPosition()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.