src/main/java/org/lightcouch/CouchDbClientBase.java
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);
		}
	}
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);
		}
	}
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.
@param <T> The class type.
@param jsonQuery The JSON query string.
@param classOfT The class of type T.
@return The result of the query as a {@code List<T> }
@throws CouchDbException If the query failed to execute or the request is invalid.
Find documents using a declarative JSON querying syntax .