Package org.bson.json
Class JsonReader
java.lang.Object
org.bson.AbstractBsonReader
org.bson.json.JsonReader
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- BsonReader
Reads a JSON in one of the following modes:
 
- Strict mode that conforms to the JSON RFC specifications.
- JavaScript mode that that most JavaScript interpreters can process
- Shell mode that the mongo shell can process. This is also called "extended" JavaScript format.
- Since:
- 3.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classAn implementation ofAbstractBsonReader.Context/protected classAn implementation ofAbstractBsonReader.Mark.Nested classes/interfaces inherited from class org.bson.AbstractBsonReaderAbstractBsonReader.State
- 
Constructor SummaryConstructorsConstructorDescriptionJsonReader(Reader reader) Constructs a new instance with the givenReaderpositioned at a JSON object.JsonReader(String json) Constructs a new instance with the given string positioned at a JSON object.
- 
Method SummaryModifier and TypeMethodDescriptionprotected intHandles the logic to peek at the binary size.protected byteHandles the logic to peek at the binary subtype.protected BsonBinaryHandles the logic to read binary dataprotected booleanHandles the logic to read booleansprotected longHandles the logic to read date timeprotected BsonDbPointerHandles the logic to read a DBPointerHandles the logic to read Decimal128protected doubleHandles the logic to read doublesprotected voidHandles the logic when reading the end of an arrayprotected voidHandles the logic when reading the end of a documentprotected intHandles the logic to read 32 bit intsprotected longHandles the logic to read 64 bit intsprotected StringHandles the logic to read JavaScript functionsprotected StringHandles the logic to read scoped JavaScript functionsprotected voidHandles the logic to read a Max keyprotected voidHandles the logic to read a Min keyprotected voidHandles the logic to read a null valueprotected ObjectIdHandles the logic to read an ObjectIdprotected BsonRegularExpressionHandles the logic to read a regular expressionprotected voidHandles the logic to read the start of an arrayprotected voidHandles the logic to read the start of a documentprotected StringHandles the logic to read a Stringprotected StringHandles the logic to read a Symbolprotected BsonTimestampHandles the logic to read a timestampprotected voidHandles the logic to read an Undefined valueprotected voidHandles any logic required to skip the name (reader must be positioned on a name).protected voidHandles any logic required to skip the value (reader must be positioned on a value).protected JsonReader.ContextGet the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.getMark()Gets a mark representing the current state of the reader.Reads a BSONType from the reader.Methods inherited from class org.bson.AbstractBsonReadercheckPreconditions, close, getCurrentBsonType, getCurrentName, getNextState, getState, isClosed, peekBinarySize, peekBinarySubType, readBinaryData, readBinaryData, readBoolean, readBoolean, readDateTime, readDateTime, readDBPointer, readDBPointer, readDecimal128, readDecimal128, readDouble, readDouble, readEndArray, readEndDocument, readInt32, readInt32, readInt64, readInt64, readJavaScript, readJavaScript, readJavaScriptWithScope, readJavaScriptWithScope, readMaxKey, readMaxKey, readMinKey, readMinKey, readName, readName, readNull, readNull, readObjectId, readObjectId, readRegularExpression, readRegularExpression, readStartArray, readStartDocument, readString, readString, readSymbol, readSymbol, readTimestamp, readTimestamp, readUndefined, readUndefined, setContext, setCurrentBsonType, setCurrentName, setState, skipName, skipValue, throwInvalidContextType, throwInvalidState, verifyBSONType, verifyName
- 
Constructor Details- 
JsonReaderConstructs a new instance with the given string positioned at a JSON object.- Parameters:
- json- A string representation of a JSON object.
 
- 
JsonReaderConstructs a new instance with the givenReaderpositioned at a JSON object.The application is responsible for closing the Reader.- Parameters:
- reader- A reader representation of a JSON object.
- Since:
- 3.11
 
 
- 
- 
Method Details- 
doReadBinaryDataDescription copied from class:AbstractBsonReaderHandles the logic to read binary data- Specified by:
- doReadBinaryDatain class- AbstractBsonReader
- Returns:
- the BsonBinary value
 
- 
doPeekBinarySubTypeprotected byte doPeekBinarySubType()Description copied from class:AbstractBsonReaderHandles the logic to peek at the binary subtype.- Specified by:
- doPeekBinarySubTypein class- AbstractBsonReader
- Returns:
- the binary subtype
 
- 
doPeekBinarySizeprotected int doPeekBinarySize()Description copied from class:AbstractBsonReaderHandles the logic to peek at the binary size.- Specified by:
- doPeekBinarySizein class- AbstractBsonReader
- Returns:
- the binary size
 
- 
doReadBooleanprotected boolean doReadBoolean()Description copied from class:AbstractBsonReaderHandles the logic to read booleans- Specified by:
- doReadBooleanin class- AbstractBsonReader
- Returns:
- the boolean value
 
- 
readBsonTypeDescription copied from interface:BsonReaderReads a BSONType from the reader.- Specified by:
- readBsonTypein interface- BsonReader
- Specified by:
- readBsonTypein class- AbstractBsonReader
- Returns:
- A BSONType.
 
- 
doReadDecimal128Description copied from class:AbstractBsonReaderHandles the logic to read Decimal128- Specified by:
- doReadDecimal128in class- AbstractBsonReader
- Returns:
- the Decimal128 value
 
- 
doReadDateTimeprotected long doReadDateTime()Description copied from class:AbstractBsonReaderHandles the logic to read date time- Specified by:
- doReadDateTimein class- AbstractBsonReader
- Returns:
- the long value
 
- 
doReadDoubleprotected double doReadDouble()Description copied from class:AbstractBsonReaderHandles the logic to read doubles- Specified by:
- doReadDoublein class- AbstractBsonReader
- Returns:
- the double value
 
- 
doReadEndArrayprotected void doReadEndArray()Description copied from class:AbstractBsonReaderHandles the logic when reading the end of an array- Specified by:
- doReadEndArrayin class- AbstractBsonReader
 
- 
doReadEndDocumentprotected void doReadEndDocument()Description copied from class:AbstractBsonReaderHandles the logic when reading the end of a document- Specified by:
- doReadEndDocumentin class- AbstractBsonReader
 
- 
doReadInt32protected int doReadInt32()Description copied from class:AbstractBsonReaderHandles the logic to read 32 bit ints- Specified by:
- doReadInt32in class- AbstractBsonReader
- Returns:
- the int value
 
- 
doReadInt64protected long doReadInt64()Description copied from class:AbstractBsonReaderHandles the logic to read 64 bit ints- Specified by:
- doReadInt64in class- AbstractBsonReader
- Returns:
- the long value
 
- 
doReadJavaScriptDescription copied from class:AbstractBsonReaderHandles the logic to read JavaScript functions- Specified by:
- doReadJavaScriptin class- AbstractBsonReader
- Returns:
- the String value
 
- 
doReadJavaScriptWithScopeDescription copied from class:AbstractBsonReaderHandles the logic to read scoped JavaScript functions- Specified by:
- doReadJavaScriptWithScopein class- AbstractBsonReader
- Returns:
- the String value
 
- 
doReadMaxKeyprotected void doReadMaxKey()Description copied from class:AbstractBsonReaderHandles the logic to read a Max key- Specified by:
- doReadMaxKeyin class- AbstractBsonReader
 
- 
doReadMinKeyprotected void doReadMinKey()Description copied from class:AbstractBsonReaderHandles the logic to read a Min key- Specified by:
- doReadMinKeyin class- AbstractBsonReader
 
- 
doReadNullprotected void doReadNull()Description copied from class:AbstractBsonReaderHandles the logic to read a null value- Specified by:
- doReadNullin class- AbstractBsonReader
 
- 
doReadObjectIdDescription copied from class:AbstractBsonReaderHandles the logic to read an ObjectId- Specified by:
- doReadObjectIdin class- AbstractBsonReader
- Returns:
- the ObjectId value
 
- 
doReadRegularExpressionDescription copied from class:AbstractBsonReaderHandles the logic to read a regular expression- Specified by:
- doReadRegularExpressionin class- AbstractBsonReader
- Returns:
- the BsonRegularExpression value
 
- 
doReadDBPointerDescription copied from class:AbstractBsonReaderHandles the logic to read a DBPointer- Specified by:
- doReadDBPointerin class- AbstractBsonReader
- Returns:
- the BsonDbPointer value
 
- 
doReadStartArrayprotected void doReadStartArray()Description copied from class:AbstractBsonReaderHandles the logic to read the start of an array- Specified by:
- doReadStartArrayin class- AbstractBsonReader
 
- 
doReadStartDocumentprotected void doReadStartDocument()Description copied from class:AbstractBsonReaderHandles the logic to read the start of a document- Specified by:
- doReadStartDocumentin class- AbstractBsonReader
 
- 
doReadStringDescription copied from class:AbstractBsonReaderHandles the logic to read a String- Specified by:
- doReadStringin class- AbstractBsonReader
- Returns:
- the String value
 
- 
doReadSymbolDescription copied from class:AbstractBsonReaderHandles the logic to read a Symbol- Specified by:
- doReadSymbolin class- AbstractBsonReader
- Returns:
- the String value
 
- 
doReadTimestampDescription copied from class:AbstractBsonReaderHandles the logic to read a timestamp- Specified by:
- doReadTimestampin class- AbstractBsonReader
- Returns:
- the BsonTimestamp value
 
- 
doReadUndefinedprotected void doReadUndefined()Description copied from class:AbstractBsonReaderHandles the logic to read an Undefined value- Specified by:
- doReadUndefinedin class- AbstractBsonReader
 
- 
doSkipNameprotected void doSkipName()Description copied from class:AbstractBsonReaderHandles any logic required to skip the name (reader must be positioned on a name).- Specified by:
- doSkipNamein class- AbstractBsonReader
 
- 
doSkipValueprotected void doSkipValue()Description copied from class:AbstractBsonReaderHandles any logic required to skip the value (reader must be positioned on a value).- Specified by:
- doSkipValuein class- AbstractBsonReader
 
- 
getMarkDescription copied from interface:BsonReaderGets a mark representing the current state of the reader.- Returns:
- the mark
 
- 
getContextDescription copied from class:AbstractBsonReaderGet the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.- Overrides:
- getContextin class- AbstractBsonReader
- Returns:
- the context
 
 
-