printjson
Printjson is a built-in function in the MongoDB shell (classic mongo and modern mongosh) used to display objects as a human-readable, JSON-like representation. It is commonly used to inspect documents, query results, or other values during interactive scripting and debugging.
The function outputs multi-line, indented JSON-like text. It preserves BSON-specific types by rendering them as their
Usage: You can pass a JavaScript object to printjson, or use it to display the result of
Relationship to other functions: Printjson is similar to tojson in that both provide a JSON-like representation,
Limitations and scope: It is intended for debugging and presentation, not for programmatic data exchange. In