Can someone briefly explain what happens when converting a plaintext JSON document to a BSON document (and vice versa: BSON to plaintext JSON) using the tojson() and fromjson() functions in MongoDB
For example, does any sorting of the key-value pairs in objects happen? Does the order of values change in any way? Is everything done in one pass? Are the functions slower/faster for certain documents (eg. arrays vs objects, slower/faster for certain data types, deeper vs longer documents)? What are the most expensive operations? Does someone know the time and space complexities (big O) of these two functions?
How would you describe how the tojson() and fromjson() functions work?