public < T > List < T > findDocs ( String jsonQuery , Class < T > classOfT ) { assertNotEmpty ( jsonQuery , "jsonQuery" ) ; HttpResponse response = null ; try { response = post ( buildUri ( getDBUri ( ) ) . path ( "_find" ) . build ( ) , jsonQuery ) ; Reader reader = new InputStreamReader ( getStream ( response ) , Charsets . UTF_8 ) ; JsonArray jsonArray = new JsonParser ( ) . parse ( reader ) . getAsJsonObject ( ) . getAsJsonArray ( "docs" ) ; List < T > list = new ArrayList < T > ( ) ; for ( JsonElement jsonElem : jsonArray ) { JsonElement elem = jsonElem . getAsJsonObject ( ) ; T t = this . gson . fromJson ( elem , classOfT ) ; list . add ( t ) ; } return list ; } finally { close ( response ) ; } }
Find documents using a declarative JSON querying syntax .