I have a string with an aggregate json query (loaded from a file) for mongodb. In robomongo, it works well. So in robomongo, I have:
db.getCollection(\'Odds\
You are not far from the solution:
The aggregate function takes: .aggregate(List<DBObject>)
But the JSON.parse you want to use lets you typecast into it, if you have a list in your query, so no Problem
String query="[....}";
List<DBObject> q= (List<DBObject>)JSON.parse(query);
Iterable<DBObject> result=new MongoClient().getDatabase("db").getCollection("coll").aggregate(q).results();`
The results can than be iterated.