Package org.bson.json

Class JsonObject

  • All Implemented Interfaces:

    public class JsonObject
    extends Object
    implements 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.
    • Constructor Detail

      • JsonObject

        public JsonObject​(String json)
        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.
        json - the JSON object string
    • Method Detail

      • getJson

        public String getJson()
        Gets the JSON object string
        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 interface Bson
        Type Parameters:
        TDocument - the type of the document class
        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 returned BsonDocument based on some knowledge of the document class.
        registry - the codec registry. This parameter may be ignored, but it may be used to look up Codec instances for the document class or any other related class.
        the BsonDocument
      • hashCode

        public int hashCode()
        hashCode in class Object