|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.json.JsonReader
public class JsonReader
A JSON reader that reads a JSON object or
array from an input source.
For example, an empty JSON array can be created as follows:
It uses
JsonReader jsonReader = new JsonReader(new StringReader("[]"));
JsonArray array = jsonReader.readArray();
jsonReader.close();
JsonParser for parsing. The parser
is created using one of the Json's createParser methods.
| Constructor Summary | |
|---|---|
JsonReader(InputStream in)
Creates a JSON reader from a byte stream. |
|
JsonReader(InputStream in,
String encoding)
Creates a JSON reader from a byte stream. |
|
JsonReader(InputStream in,
String encoding,
JsonConfiguration config)
Creates a JSON reader from a byte stream. |
|
JsonReader(Reader reader)
Creates a JSON reader from a character stream |
|
JsonReader(Reader reader,
JsonConfiguration config)
Creates a JSON reader from a character stream |
|
| Method Summary | |
|---|---|
void |
close()
Closes this reader and frees any resources associated with the reader. |
JsonStructure |
read()
Returns a JSON array or object that is represented in the input source. |
JsonArray |
readArray()
Returns a JSON array that is represented in the input source. |
JsonObject |
readObject()
Returns a JSON object that is represented in the input source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JsonReader(Reader reader)
reader - a reader from which JSON is to be read
public JsonReader(Reader reader,
JsonConfiguration config)
reader - a character stream from which JSON is to be readconfig - configuration of the reader
IllegalArgumentException - if a feature in the configuration
is not knownpublic JsonReader(InputStream in)
in - a byte stream from which JSON is to be read
public JsonReader(InputStream in,
String encoding)
in - a byte stream from which JSON is to be readencoding - the name of character
encoding of the stream.
JsonException - if the named encoding is not supported. The
cause of the exception would be
UnsupportedEncodingExceptionCharset
public JsonReader(InputStream in,
String encoding,
JsonConfiguration config)
in - a byte stream from which JSON is to be readencoding - the name of character
encoding of the stream.config - configuration of the reader
JsonException - if the named encoding is not supported. The
cause of the exception would be
UnsupportedEncodingException
IllegalArgumentException - if a feature in the configuration
is not knownCharset| Method Detail |
|---|
public JsonStructure read()
JsonException - if a JSON object or array cannot
be created due to i/o error or incorrect representation
IllegalStateException - if this method, readObject, readArray or
close method is already calledpublic JsonObject readObject()
JsonException - if a JSON object or array cannot
be created due to i/o error or incorrect representation
IllegalStateException - if this method, readObject, readArray or
close method is already calledpublic JsonArray readArray()
JsonException - if a JSON object or array cannot
be created due to i/o error or incorrect representation
IllegalStateException - if this method, readObject, readArray or
close method is already calledpublic void close()
close in interface Closeable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||