Package com.unboundid.util.json
Class JSONObjectReader
java.lang.Object
com.unboundid.util.json.JSONObjectReader
- All Implemented Interfaces:
Closeable,AutoCloseable
@ThreadSafety(level=NOT_THREADSAFE)
public final class JSONObjectReader
extends Object
implements Closeable
This class provides a mechanism for reading JSON objects from an input
stream. It assumes that any non-ASCII data that may be read from the input
stream is encoded as UTF-8.
-
Constructor Summary
ConstructorsConstructorDescriptionJSONObjectReader(InputStream inputStream) Creates a new JSON object reader that will read objects from the provided input stream.JSONObjectReader(InputStream inputStream, boolean bufferInputStream) Creates a new JSON object reader that will read objects from the provided input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this JSON object reader and the underlying input stream.Reads the next JSON object from the input stream.
-
Constructor Details
-
JSONObjectReader
Creates a new JSON object reader that will read objects from the provided input stream.- Parameters:
inputStream- The input stream from which the data should be read.
-
JSONObjectReader
Creates a new JSON object reader that will read objects from the provided input stream.- Parameters:
inputStream- The input stream from which the data should be read.bufferInputStream- Indicates whether to buffer the input stream. This should befalseif the input stream could be used for any purpose other than reading JSON objects after one or more objects are read.
-
-
Method Details
-
readObject
Reads the next JSON object from the input stream.- Returns:
- The JSON object that was read, or
nullif the end of the end of the stream has been reached. - Throws:
IOException- If a problem is encountered while reading from the input stream.JSONException- If the data read
-
close
Closes this JSON object reader and the underlying input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If a problem is encountered while closing the underlying input stream.
-