public class SimpleJsonParser
extends java.lang.Object
The data will be mapped on the following Java types:
It is based on the RFC-7159 (http://tools.ietf.org/html/rfc7159).
Constructor and Description |
---|
SimpleJsonParser()
Creates a new parser.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkNextMandatoryToken(char expectedChar) |
static SimpleJsonParser |
create()
Creates a new parser.
|
protected JsonArray |
createArray() |
protected JsonObject |
createObject() |
org.pfsw.text.json.CharEscaper |
getCharEscaper() |
protected java.lang.String |
getCurrentStringRegion(int backwards,
int forwards)
Just for debugging purposes!
|
protected int |
getLastPosition() |
protected char |
getStringDelimiter() |
protected StringExaminer |
getStringExaminer() |
protected boolean |
isArrayEnd(char ch) |
protected boolean |
isArrayStart(char ch) |
protected boolean |
isEscape(char ch) |
protected boolean |
isNumberStart(char ch) |
protected boolean |
isObjectEnd(char ch) |
protected boolean |
isObjectStart(char ch) |
protected boolean |
isStringEnd(char ch) |
protected boolean |
isStringStart(char ch) |
protected boolean |
isValueSeparator(char ch) |
protected char |
nextChar()
Returns simply the next character of the underlying JSON string.
|
protected char |
nextNoneWhitespaceChar()
Looks for the next character that is no white space and returns it.
|
java.lang.Object |
parse(java.lang.String jsonText)
Parse the given JSON text and return its Java representation.
|
protected JsonArray |
parseArray() |
JsonArray |
parseArray(java.lang.String jsonText)
Parse the given JSON text and return its Java representation as JsonArray.
|
protected java.lang.Object |
parseInternal() |
protected void |
parseKeyValueInto(java.util.Map<java.lang.String,java.lang.Object> jsonObject) |
protected java.lang.Object |
parseLiteral() |
protected java.lang.String |
parseLiteralString(int maxLength,
java.lang.String allowedChars) |
protected java.lang.Number |
parseNumber()
Returns either an Integer, a Long or a BigDecimal.
|
protected JsonObject |
parseObject() |
JsonObject |
parseObject(java.lang.String jsonText)
Parse the given JSON text and return its Java representation as JsonObject.
|
protected java.lang.String |
parseString() |
protected <T extends JsonType> |
parseTo(java.lang.String json,
java.lang.Class<T> resultType) |
protected java.lang.String |
parseUpToQuote() |
protected java.lang.Object |
parseValue() |
protected char |
peekNextChar()
Returns the next character of the underlying JSON string without moving the
examiner's position forward.
|
protected char |
peekNextNoneWhitespaceChar()
Looks for the next character that is no white space and returns it.
|
protected void |
setStringExaminer(StringExaminer stringExaminer) |
public static SimpleJsonParser create()
public java.lang.Object parse(java.lang.String jsonText) throws JsonParseException
jsonText
- The JSON text to be parsed (must not be null).JsonParseException
- Any parsing problem.public JsonObject parseObject(java.lang.String jsonText) throws JsonParseException
jsonText
- The JSON text to be parsed (must not be null).JsonParseException
- Any parsing problem.java.lang.ClassCastException
- If the JSON text did not represent a JSON object.public JsonArray parseArray(java.lang.String jsonText) throws JsonParseException
jsonText
- The JSON text to be parsed (must not be null).JsonParseException
- Any parsing problem.java.lang.ClassCastException
- If the JSON text did not represent a JSON array.protected boolean isObjectStart(char ch)
protected boolean isObjectEnd(char ch)
protected boolean isArrayStart(char ch)
protected boolean isArrayEnd(char ch)
protected boolean isStringStart(char ch)
protected boolean isStringEnd(char ch)
protected boolean isEscape(char ch)
protected boolean isValueSeparator(char ch)
protected boolean isNumberStart(char ch)
protected java.lang.Object parseInternal() throws JsonParseException
JsonParseException
protected java.lang.Object parseValue() throws JsonParseException
JsonParseException
protected JsonObject parseObject() throws JsonParseException
JsonParseException
protected void parseKeyValueInto(java.util.Map<java.lang.String,java.lang.Object> jsonObject) throws JsonParseException
JsonParseException
protected JsonArray parseArray() throws JsonParseException
JsonParseException
protected java.lang.String parseString() throws JsonParseException
JsonParseException
protected java.lang.String parseUpToQuote() throws JsonParseException
JsonParseException
protected java.lang.Number parseNumber() throws JsonParseException
JsonParseException
- If the string cannot be parsed to a number.protected java.lang.String parseLiteralString(int maxLength, java.lang.String allowedChars) throws JsonParseException
JsonParseException
protected java.lang.Object parseLiteral() throws JsonParseException
JsonParseException
protected <T extends JsonType> T parseTo(java.lang.String json, java.lang.Class<T> resultType) throws JsonParseException
JsonParseException
protected int getLastPosition()
protected void checkNextMandatoryToken(char expectedChar) throws JsonParseException
JsonParseException
protected char nextNoneWhitespaceChar() throws JsonParseException
JsonParseException
- If the end of the underlying JSON data was reached.protected char nextChar() throws JsonParseException
JsonParseException
- If the end of the underlying JSON data was reached.protected char peekNextChar()
protected char peekNextNoneWhitespaceChar() throws JsonParseException
JsonParseException
- If the end of the underlying JSON data was reached.protected char getStringDelimiter()
protected JsonObject createObject()
protected JsonArray createArray()
protected StringExaminer getStringExaminer()
protected void setStringExaminer(StringExaminer stringExaminer)
public org.pfsw.text.json.CharEscaper getCharEscaper()
protected java.lang.String getCurrentStringRegion(int backwards, int forwards)