I´m quite confused about java drivers for Mongodb. Reading the official documentation it seems that you can use the normal MondoDB Driver or the MongoDB Async Driver.
The first question is: Can I use both in the same application or I have to choose one?
Trying to use the Async driver I found things that I used to do (with the normal driver) in which I get a bit lost now. For example, I used to do this:
FindIterable<Document> iterable = db.getCollection("my_coll").find(query);
String json = JSON.serialize(iterable);
And now I really don´t know how to convert the result into a json string since they have not included the JSON
class from the Async driver.
Second question: If I cannot use both drivers at the same time, how can I then serialize a FindIterable<Document>
?
The answers are:
JSON
class:JSON.serialize(iterable);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With