本文整理了Java中io.vertx.ext.web.client.HttpResponse.bodyAsJsonArray()
方法的一些代码示例,展示了HttpResponse.bodyAsJsonArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.bodyAsJsonArray()
方法的具体详情如下:
包路径:io.vertx.ext.web.client.HttpResponse
类名称:HttpResponse
方法名:bodyAsJsonArray
暂无
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* @return the response body decoded as a , or <code>null</code> if a codec other than was used
*/
public JsonArray bodyAsJsonArray() {
if (cached_10 != null) {
return cached_10;
}
JsonArray ret = delegate.bodyAsJsonArray();
cached_10 = ret;
return ret;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* @return the response body decoded as a , or <code>null</code> if a codec other than was used
*/
public JsonArray bodyAsJsonArray() {
if (cached_10 != null) {
return cached_10;
}
JsonArray ret = delegate.bodyAsJsonArray();
cached_10 = ret;
return ret;
}
代码示例来源:origin: io.vertx/vertx-lang-groovy
public static java.util.List<Object> bodyAsJsonArray(io.vertx.ext.web.client.HttpResponse<Object> j_receiver) {
return io.vertx.core.impl.ConversionHelper.fromJsonArray(j_receiver.bodyAsJsonArray());
}
public static <R>java.lang.Object bodyAsJson(io.vertx.ext.web.client.HttpResponse<Object> j_receiver, java.lang.Class<java.lang.Object> type) {
代码示例来源:origin: io.vertx/vertx-consul-client
private <T> void requestArray(HttpMethod method, String path, Query query, String body,
Handler<AsyncResult<T>> resultHandler,
BiFunction<JsonArray, MultiMap, T> mapper) {
request(DEFAULT_VALID_CODES, method, path, query, body, resultHandler, resp -> mapper.apply(resp.bodyAsJsonArray(), resp.headers()));
}
代码示例来源:origin: io.vertx/vertx-consul-client
@Override
public ConsulClient getKeysWithOptions(String keyPrefix, BlockingQueryOptions options, Handler<AsyncResult<List<String>>> resultHandler) {
Query query = Query.of("recurse", true).put("keys", true).put(options);
request(KV_VALID_CODES, HttpMethod.GET, "/v1/kv/" + urlEncode(keyPrefix), query, null, resultHandler, resp -> {
if (resp.statusCode() == HttpResponseStatus.NOT_FOUND.code()) {
return new ArrayList<>();
} else {
return resp.bodyAsJsonArray().stream().map(Object::toString).collect(Collectors.toList());
}
});
return this;
}
代码示例来源:origin: io.vertx/vertx-consul-client
@Override
public ConsulClient getValuesWithOptions(String keyPrefix, BlockingQueryOptions options, Handler<AsyncResult<KeyValueList>> resultHandler) {
Query query = Query.of("recurse", true).put(options);
request(KV_VALID_CODES, HttpMethod.GET, "/v1/kv/" + urlEncode(keyPrefix), query, null, resultHandler, resp -> {
if (resp.statusCode() == HttpResponseStatus.NOT_FOUND.code()) {
return new KeyValueList();
} else {
List<KeyValue> list = resp.bodyAsJsonArray().stream().map(obj -> KVParser.parse((JsonObject) obj)).collect(Collectors.toList());
return new KeyValueList().setList(list).setIndex(Long.parseLong(resp.headers().get(INDEX_HEADER)));
}
});
return this;
}
代码示例来源:origin: io.vertx/vertx-consul-client
@Override
public ConsulClient getValueWithOptions(String key, BlockingQueryOptions options, Handler<AsyncResult<KeyValue>> resultHandler) {
request(KV_VALID_CODES, HttpMethod.GET, "/v1/kv/" + urlEncode(key), new Query().put(options), null, resultHandler, resp -> {
if (resp.statusCode() == HttpResponseStatus.NOT_FOUND.code()) {
return new KeyValue();
} else {
return KVParser.parse(resp.bodyAsJsonArray().getJsonObject(0));
}
});
return this;
}
代码示例来源:origin: io.vertx/vertx-web-client
@Test
public void testResponseUnknownContentTypeBodyAsJsonArray() throws Exception {
JsonArray expected = new JsonArray().add("cheese").add("wine");
server.requestHandler(req -> req.response().end(expected.encode()));
startServer();
HttpRequest<Buffer> get = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath");
get.send(onSuccess(resp -> {
assertEquals(200, resp.statusCode());
assertEquals(expected, resp.bodyAsJsonArray());
testComplete();
}));
await();
}
内容来源于网络,如有侵权,请联系作者删除!