Package org.bson.json
Class JsonObject
java.lang.Object
org.bson.json.JsonObject
- All Implemented Interfaces:
Bson
A wrapper class that holds a JSON object string. This class makes decoding JSON efficient.
Note that this class only holds valid JSON objects, not arrays or other values.
- Since:
- 4.2
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY
-
Constructor Summary
ConstructorDescriptionJsonObject
(String json) Constructs a new instance with the given JSON object string. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getJson()
Gets the JSON object stringint
hashCode()
<TDocument>
BsonDocumenttoBsonDocument
(Class<TDocument> documentClass, CodecRegistry registry) Render into a BsonDocument.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bson.conversions.Bson
toBsonDocument
-
Constructor Details
-
JsonObject
Constructs a new instance with the given JSON object string. Clients must ensure they only pass in valid JSON objects to this constructor. The constructor does not perform full validation on construction, but an invalid JsonObject can cause errors when it is used later on.- Parameters:
json
- the JSON object string
-
-
Method Details
-
getJson
Gets the JSON object string- Returns:
- the JSON object string
-
toBsonDocument
public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry registry) Description copied from interface:Bson
Render into a BsonDocument.- Specified by:
toBsonDocument
in interfaceBson
- Type Parameters:
TDocument
- the type of the document class- Parameters:
documentClass
- the document class in scope for the collection. This parameter may be ignored, but it may be used to alter the structure of the returnedBsonDocument
based on some knowledge of the document class.registry
- the codec registry. This parameter may be ignored, but it may be used to look upCodec
instances for the document class or any other related class.- Returns:
- the BsonDocument
-
equals
-
hashCode
public int hashCode() -
toString
-