JSON stored as text, BSON, or UBJSON can contain specific data types depending on the storage format specification. The following table lists all extended data types of each binary storage specification and their corresponding representation in all other specifications.
Source Specification | Source Type | Target Specification | Target Type |
---|---|---|---|
BSON | Floating Point | JSON | number |
UBJSON | float32/float64 | ||
Binary Data | JSON/UBJSON |
Key/value pair: {"$type": <string representing type of binary data>, "$binary": <string representing binary data>} |
|
ObjectId | JSON/UBJSON |
Key/value pair: {"$oid": <string representing object id>} |
|
UTC datetime | JSON/UBJSON |
Key/value pair: {"$date": <number representing date>} |
|
Regular Expression | JSON/UBJSON |
Key/value pair: {"$regex": < string representing regex>, "$options": <string representing options>} |
|
DBPointer | JSON/UBJSON |
Key/value pair: {"$ref": <string representing collection>, "$id": <string representing object id>} |
|
JavaScriptCode | JSON/UBJSON | string | |
Symbol | JSON/UBJSON | string | |
JavaScript Code with scope | JSON/UBJSON | string | |
TimeStamp | JSON/UBJSON |
Key/value pair: {"$timestamp": { "$t": <number representing timestamp>, "$i": <number representing increment>} } |
|
Min key | JSON/UBJSON |
Key/value pair: {"$minKey": 1} |
|
Max key | JSON/UBJSON |
Key/value pair: {"$maxKey": 1} |
|
int32 | JSON | number | |
UBJSON | int32 | ||
int64 | JSON | number | |
UBJSON | int64 | ||
UBJSON | int8 | JSON | number |
BSON | int32 | ||
int16 | JSON | number | |
BSON | int32 | ||
int32 | JSON | number | |
BSON | int32 | ||
int64 | JSON | number | |
BSON | int64 | ||
float32 | JSON | number | |
BSON | double | ||
float64 | JSON | number | |
BSON | double | ||
High-Precision Number | JSON/BSON | string | |
char | JSON/BSON | string |