Hi Aniket
You can use the Document.parse() method to create a Document instance from a JSON string: http://mongodb.github.io/mongo-java-driver/3.5/javadoc/org/bson/Document.html#parse-java.lang.String-
For example, this Java snippet follows the example in the $redact page and will produce the same output:
MongoIterable<Document> agg = collection.aggregate(
Arrays.asList(
Document.parse("{$match: {'year': 2014}}"),
Document.parse("{ $redact: {" +
"$cond: {" +
"if: { $gt: [ { $size: { $setIntersection: [ '$tags', ['STLW', 'G'] ] } }, 0 ] }," +
"then: '$$DESCEND'," +
"else: '$$PRUNE'" +
"}}}")
)
);
Best regards
Kevin