Package ej.json
Class JSONReader
- java.lang.Object
-
- ej.json.JSONReader
-
public class JSONReader extends Object
A JSONReader takes a sourceInputStreamand extracts characters and tokens from it.
-
-
Constructor Summary
Constructors Constructor Description JSONReader(InputStream is)Construct a JSONReader from anInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarrayEnd()End an array.voidarrayStart()Start an array.voidmapEnd()End a map.voidmapStart()Start a map.StringnextKey()Get the next key as String.ObjectnextValue()Get the next value.charpeek()Get the first character of the next token.
-
-
-
Field Detail
-
NULL
public static final Object NULL
It is sometimes more convenient and less ambiguous to have aNULLobject than to use Java'snullvalue.NULL.equals(null)returnstrue.NULL.toString()returns"null".
-
-
Constructor Detail
-
JSONReader
public JSONReader(InputStream is)
Construct a JSONReader from anInputStream.- Parameters:
is- the InputStream.
-
-
Method Detail
-
peek
public char peek() throws JSONExceptionGet the first character of the next token.- Returns:
- the first character or
0on EOF. - Throws:
JSONException- on I/O error
-
nextKey
public String nextKey() throws JSONException
Get the next key as String.- Returns:
- A String
- Throws:
JSONException- If syntax error.
-
arrayStart
public void arrayStart() throws JSONExceptionStart an array.- Throws:
JSONException- If syntax error.
-
arrayEnd
public void arrayEnd() throws JSONExceptionEnd an array.- Throws:
JSONException- If syntax error.
-
mapStart
public void mapStart() throws JSONExceptionStart a map.- Throws:
JSONException- If syntax error.
-
mapEnd
public void mapEnd() throws JSONExceptionEnd a map.- Throws:
JSONException- If syntax error.
-
nextValue
public Object nextValue() throws JSONException
Get the next value. The value can be a Boolean, Double, Integer, Long, or String, or theJSONReader.Nullobject.- Returns:
- An object or null if the beginning of array or a map is reached.
- Throws:
JSONException- If syntax error.
-
-