content_image/664400.jpg
This operation will return the following hexadecimal string: 

507f191e810c19729de860ea 

To return the hexadecimal string representation of an ObjectId() , use the valueOf() method as follows: 

ObjectId("507f191e810c19729de860ea").valueOf() 

This operation returns the following output: 

507f191e810c19729de860ea 

To return the string representation of an ObjectId() object (in the form of a string literal ObjectId(...) ), use the toString() method as follows: 

ObjectId("507f191e810c19729de860ea").toString() 

This operation will return the following string output: 

ObjectId("507f191e810c19729de860ea") 

## 4.4.5 BSON Types 

BSON is a binary serialization format used to store documents and make remote procedure calls in MongoDB. The BSON specification is located at bsonspec.org$^{28}$. 

BSON supports the following data types as values in documents. Each data type has a corresponding number that can be used with the $type operator to query documents by BSON type. 

<img src='content_image/664400.jpg'>

To determine a field’s type, see Check Types in the mongo Shell (page 269). 

If you convert BSON to JSON, see the Extended JSON reference. 

$^{28}$http://bsonspec.org/ 

