[JAVA-1646] Interpret String instances as JSON Created: 09/Feb/15  Updated: 27/Feb/15  Resolved: 25/Feb/15

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

Type: New Feature Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

One advantage of the new CRUD API in MongoCollection taking instances of Object (instead of Document) is that it can interpret String instances as JSON, which would allow usage like:

MongoCollection<Document> collection;
 
collection.find().filter("{filter: 2}")
                        .sort("{name: 1}")
                        .projection("{projection: 2}")



 Comments   
Comment by Jeffrey Yemin [ 25/Feb/15 ]

Superseded by JAVA-1659. MongoCollection no longer takes Object. So you have to do something like:

  collection.find(BsonDocument.parse("{x : 1}'))
                 .sort(BsonDocument.parse("{y: 1}'))
                 .projection(BsonDocument.parse("{y : 1}'));

The parse method can be statically imported to remove some of the verbosity.

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