Class JsonReader
- All Implemented Interfaces:
- AutoCloseable,- Iterable<MapValue>
 As an iteration proceeds it may return any number of valid MapValue
 instances before it encounters a problem in the input stream such as a bad
 object or unexpected end of file. It is up to the application to handle
 error conditions. There is no mechanism for restarting in the middle of
 a file or string. If a JsonParseException is thrown it will
 contain the location of the exception in the parse stream to help isolate
 problems.
 
An instance of this class can only be used to create a single iterator. This is to ensure that the Iterator can be closed explicitly by the caller. If an attempt is made to create an additional iterator IllegalArgumentException is thrown.
Instances of this class must be closed when done to free parser resources. It implements AutoCloseable to assist but in the event it is not called inside a try-with-resources block an explicit close() should be used.
- 
Constructor SummaryConstructorsConstructorDescriptionJsonReader(File file, JsonOptions options) Creates an iterator over JSON objects in the specified file.JsonReader(InputStream input, JsonOptions options) Creates an iterator over JSON objects provided by the InputStream.JsonReader(Reader input, JsonOptions options) Creates an iterator over JSON objects provided by the Reader.JsonReader(String jsonString, JsonOptions options) Creates an iterator over JSON objects in a string.
- 
Method SummaryMethods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
JsonReaderCreates an iterator over JSON objects in the specified file.- Parameters:
- file- the file to be used
- options- if desired, this can be null
 
- 
JsonReaderCreates an iterator over JSON objects in a string.- Parameters:
- jsonString- the String to use
- options- if desired, this can be null
 
- 
JsonReaderCreates an iterator over JSON objects provided by the InputStream. The caller is responsible for closing the InputStream if necessary.- Parameters:
- input- the InputStream to use
- options- if desired, this can be null
 
- 
JsonReaderCreates an iterator over JSON objects provided by the Reader. The caller is responsible for closing the Reader if necessary.- Parameters:
- input- the Reader to use
- options- if desired, this can be null
 
 
- 
- 
Method Details- 
iteratorReturns an Iterator<MapValue> over the source provided. This method can only be called once for a given instance of JsonReader. An additional call will result in IllegalArgumentException being thrown.- Specified by:
- iteratorin interface- Iterable<MapValue>
- Throws:
- IllegalArgumentException- if called twice
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
 
- 
getLocationOffsetpublic long getLocationOffset()Returns the byte offset into the JSON being processed if available or -1 if not- Returns:
- the offset or -1 if not available in the underlying data being parsed
 
 
-