[JAVA-2116] How can I get to the raw json returned by a query Created: 15/Feb/16  Updated: 11/Sep/19  Resolved: 15/Feb/16

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Emrah Diril Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I'm interested in getting the raw json from my queries:
I have the following simple code:

db = new Mongo().getDB("myDatabase");
DBCollection coll = db.getCollection("myCollection");
DBCursor cursor = coll.find();

And "String raw = cursor.next().toString();" will allow me to get the raw json for my query.

However getDB() is deprecated and as far as I can tell the new getDatabase() line of API calls convert the json results to java objects automatically.

My question is, how can I get to the raw json returned by a query using the getDatabase() line of API calls like I used to?

Thanks



 Comments   
Comment by Emrah Diril [ 15/Feb/16 ]

Actually I figured out that I can use MongoCursor in a similar way. You can delete/ignore this issue.
Thanks

Generated at Thu Feb 08 08:56:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.