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 Summary
Modifier and TypeClassDescriptionprotected class
An implementation ofAbstractBsonReader.Context
/protected class
An implementation ofAbstractBsonReader.Mark
.Nested classes/interfaces inherited from class org.bson.AbstractBsonReader
AbstractBsonReader.State
-
Constructor Summary
ConstructorDescriptionJsonReader
(Reader reader) Constructs a new instance with the givenReader
positioned at a JSON object.JsonReader
(String json) Constructs a new instance with the given string positioned at a JSON object. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Handles the logic to peek at the binary size.protected byte
Handles the logic to peek at the binary subtype.protected BsonBinary
Handles the logic to read binary dataprotected boolean
Handles the logic to read booleansprotected long
Handles the logic to read date timeprotected BsonDbPointer
Handles the logic to read a DBPointerHandles the logic to read Decimal128protected double
Handles the logic to read doublesprotected void
Handles the logic when reading the end of an arrayprotected void
Handles the logic when reading the end of a documentprotected int
Handles the logic to read 32 bit intsprotected long
Handles the logic to read 64 bit intsprotected String
Handles the logic to read JavaScript functionsprotected String
Handles the logic to read scoped JavaScript functionsprotected void
Handles the logic to read a Max keyprotected void
Handles the logic to read a Min keyprotected void
Handles the logic to read a null valueprotected ObjectId
Handles the logic to read an ObjectIdprotected BsonRegularExpression
Handles the logic to read a regular expressionprotected void
Handles the logic to read the start of an arrayprotected void
Handles the logic to read the start of a documentprotected String
Handles the logic to read a Stringprotected String
Handles the logic to read a Symbolprotected BsonTimestamp
Handles the logic to read a timestampprotected void
Handles the logic to read an Undefined valueprotected void
Handles any logic required to skip the name (reader must be positioned on a name).protected void
Handles any logic required to skip the value (reader must be positioned on a value).protected JsonReader.Context
Get 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.AbstractBsonReader
checkPreconditions, 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
-
JsonReader
Constructs a new instance with the given string positioned at a JSON object.- Parameters:
json
- A string representation of a JSON object.
-
JsonReader
Constructs a new instance with the givenReader
positioned 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
-
doReadBinaryData
Description copied from class:AbstractBsonReader
Handles the logic to read binary data- Specified by:
doReadBinaryData
in classAbstractBsonReader
- Returns:
- the BsonBinary value
-
doPeekBinarySubType
protected byte doPeekBinarySubType()Description copied from class:AbstractBsonReader
Handles the logic to peek at the binary subtype.- Specified by:
doPeekBinarySubType
in classAbstractBsonReader
- Returns:
- the binary subtype
-
doPeekBinarySize
protected int doPeekBinarySize()Description copied from class:AbstractBsonReader
Handles the logic to peek at the binary size.- Specified by:
doPeekBinarySize
in classAbstractBsonReader
- Returns:
- the binary size
-
doReadBoolean
protected boolean doReadBoolean()Description copied from class:AbstractBsonReader
Handles the logic to read booleans- Specified by:
doReadBoolean
in classAbstractBsonReader
- Returns:
- the boolean value
-
readBsonType
Description copied from interface:BsonReader
Reads a BSONType from the reader.- Specified by:
readBsonType
in interfaceBsonReader
- Specified by:
readBsonType
in classAbstractBsonReader
- Returns:
- A BSONType.
-
doReadDecimal128
Description copied from class:AbstractBsonReader
Handles the logic to read Decimal128- Specified by:
doReadDecimal128
in classAbstractBsonReader
- Returns:
- the Decimal128 value
-
doReadDateTime
protected long doReadDateTime()Description copied from class:AbstractBsonReader
Handles the logic to read date time- Specified by:
doReadDateTime
in classAbstractBsonReader
- Returns:
- the long value
-
doReadDouble
protected double doReadDouble()Description copied from class:AbstractBsonReader
Handles the logic to read doubles- Specified by:
doReadDouble
in classAbstractBsonReader
- Returns:
- the double value
-
doReadEndArray
protected void doReadEndArray()Description copied from class:AbstractBsonReader
Handles the logic when reading the end of an array- Specified by:
doReadEndArray
in classAbstractBsonReader
-
doReadEndDocument
protected void doReadEndDocument()Description copied from class:AbstractBsonReader
Handles the logic when reading the end of a document- Specified by:
doReadEndDocument
in classAbstractBsonReader
-
doReadInt32
protected int doReadInt32()Description copied from class:AbstractBsonReader
Handles the logic to read 32 bit ints- Specified by:
doReadInt32
in classAbstractBsonReader
- Returns:
- the int value
-
doReadInt64
protected long doReadInt64()Description copied from class:AbstractBsonReader
Handles the logic to read 64 bit ints- Specified by:
doReadInt64
in classAbstractBsonReader
- Returns:
- the long value
-
doReadJavaScript
Description copied from class:AbstractBsonReader
Handles the logic to read JavaScript functions- Specified by:
doReadJavaScript
in classAbstractBsonReader
- Returns:
- the String value
-
doReadJavaScriptWithScope
Description copied from class:AbstractBsonReader
Handles the logic to read scoped JavaScript functions- Specified by:
doReadJavaScriptWithScope
in classAbstractBsonReader
- Returns:
- the String value
-
doReadMaxKey
protected void doReadMaxKey()Description copied from class:AbstractBsonReader
Handles the logic to read a Max key- Specified by:
doReadMaxKey
in classAbstractBsonReader
-
doReadMinKey
protected void doReadMinKey()Description copied from class:AbstractBsonReader
Handles the logic to read a Min key- Specified by:
doReadMinKey
in classAbstractBsonReader
-
doReadNull
protected void doReadNull()Description copied from class:AbstractBsonReader
Handles the logic to read a null value- Specified by:
doReadNull
in classAbstractBsonReader
-
doReadObjectId
Description copied from class:AbstractBsonReader
Handles the logic to read an ObjectId- Specified by:
doReadObjectId
in classAbstractBsonReader
- Returns:
- the ObjectId value
-
doReadRegularExpression
Description copied from class:AbstractBsonReader
Handles the logic to read a regular expression- Specified by:
doReadRegularExpression
in classAbstractBsonReader
- Returns:
- the BsonRegularExpression value
-
doReadDBPointer
Description copied from class:AbstractBsonReader
Handles the logic to read a DBPointer- Specified by:
doReadDBPointer
in classAbstractBsonReader
- Returns:
- the BsonDbPointer value
-
doReadStartArray
protected void doReadStartArray()Description copied from class:AbstractBsonReader
Handles the logic to read the start of an array- Specified by:
doReadStartArray
in classAbstractBsonReader
-
doReadStartDocument
protected void doReadStartDocument()Description copied from class:AbstractBsonReader
Handles the logic to read the start of a document- Specified by:
doReadStartDocument
in classAbstractBsonReader
-
doReadString
Description copied from class:AbstractBsonReader
Handles the logic to read a String- Specified by:
doReadString
in classAbstractBsonReader
- Returns:
- the String value
-
doReadSymbol
Description copied from class:AbstractBsonReader
Handles the logic to read a Symbol- Specified by:
doReadSymbol
in classAbstractBsonReader
- Returns:
- the String value
-
doReadTimestamp
Description copied from class:AbstractBsonReader
Handles the logic to read a timestamp- Specified by:
doReadTimestamp
in classAbstractBsonReader
- Returns:
- the BsonTimestamp value
-
doReadUndefined
protected void doReadUndefined()Description copied from class:AbstractBsonReader
Handles the logic to read an Undefined value- Specified by:
doReadUndefined
in classAbstractBsonReader
-
doSkipName
protected void doSkipName()Description copied from class:AbstractBsonReader
Handles any logic required to skip the name (reader must be positioned on a name).- Specified by:
doSkipName
in classAbstractBsonReader
-
doSkipValue
protected void doSkipValue()Description copied from class:AbstractBsonReader
Handles any logic required to skip the value (reader must be positioned on a value).- Specified by:
doSkipValue
in classAbstractBsonReader
-
getMark
Description copied from interface:BsonReader
Gets a mark representing the current state of the reader.- Returns:
- the mark
-
getContext
Description copied from class:AbstractBsonReader
Get the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.- Overrides:
getContext
in classAbstractBsonReader
- Returns:
- the context
-