public <T> Single<T> requestJson(final Class<T> clazz) {
        headers("Accept", "application/json, text/javascript, */*; q=0.01");
        return requestInternal(r -> {
            T result;
            final String bodyString = r.getBodyString();
            r.close();
            try {
                result = JSON_MAPPER.readValue(bodyString, clazz);
            } catch (JsonProcessingException jpe) {
                final String errorMsg = LOGPRAEFIX + "ERR: could not parse json String to '" + clazz.getName() + "': " + bodyString;
                if (HttpResponse.class.isAssignableFrom(clazz)) {
                    Log.w(errorMsg, jpe);
                    try {
                        result = clazz.newInstance();
                        ((HttpResponse) result).setFailed(jpe);
                    } catch (ReflectiveOperationException roe) {
                        //should never happen, but in case it does...
                        throw new IllegalStateException(LOGPRAEFIX + "ERR: Couldn't create class instance: '" + clazz.getName() + "'", roe);
                    }
                } else {
                    throw new IllegalArgumentException(errorMsg, jpe);
                }
            }
            return result;
        });
    }
Convenience class used to ensapculate the building and usage of a HtmlRequest
main/src/main/java/cgeo/geocaching/network/HttpRequest.java