本文整理了Java中io.vertx.core.buffer.Buffer.toJsonArray()
方法的一些代码示例,展示了Buffer.toJsonArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.toJsonArray()
方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:toJsonArray
[英]Returns a Json array representation of the Buffer
[中]返回缓冲区的Json数组表示形式
代码示例来源:origin: vert-x3/vertx-examples
public JsonArray getJsonArray() {
return isArray() ? buffer.toJsonArray() : null;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testToJsonArray() throws Exception {
JsonArray arr = new JsonArray();
arr.add("wibble");
arr.add(5);
arr.add(true);
Buffer buff = Buffer.buffer(arr.encode());
assertEquals(arr, buff.toJsonArray());
buff = Buffer.buffer(TestUtils.randomAlphaString(10));
try {
buff.toJsonObject();
fail();
} catch (DecodeException ignore) {
}
}
代码示例来源:origin: vert-x3/vertx-examples
handler.handle(new Batch(payload.toJsonArray()));
break;
代码示例来源:origin: mewna/catnip
public JsonArray array() {
return buffer.toJsonArray();
}
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Returns a Json array representation of the Buffer
* @return
*/
public JsonArray toJsonArray() {
JsonArray ret = delegate.toJsonArray();
return ret;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Returns a Json array representation of the Buffer
* @return
*/
public JsonArray toJsonArray() {
JsonArray ret = delegate.toJsonArray();
return ret;
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testToJsonArray() throws Exception {
JsonArray arr = new JsonArray();
arr.add("wibble");
arr.add(5);
arr.add(true);
Buffer buff = Buffer.buffer(arr.encode());
assertEquals(arr, buff.toJsonArray());
buff = Buffer.buffer(TestUtils.randomAlphaString(10));
try {
buff.toJsonObject();
fail();
} catch (DecodeException ignore) {
}
}
代码示例来源:origin: vert-x3/vertx-kafka-client
@Override
public JsonArray deserialize(String topic, byte[] data) {
if (data == null)
return null;
return Buffer.buffer(data).toJsonArray();
}
代码示例来源:origin: io.vertx/vertx-lang-groovy
public static java.util.List<Object> toJsonArray(io.vertx.core.buffer.Buffer j_receiver) {
return io.vertx.core.impl.ConversionHelper.fromJsonArray(j_receiver.toJsonArray());
}
}
代码示例来源:origin: vert-x3/vertx-config
break;
case "json-array":
json.put(key, input.toJsonArray());
handler.handle(Future.succeededFuture(json));
break;
代码示例来源:origin: io.vertx/vertx-config
break;
case "json-array":
json.put(key, input.toJsonArray());
handler.handle(Future.succeededFuture(json));
break;
代码示例来源:origin: eclipse/hono
private Future<Void> addAll(final Buffer deviceIdentities) {
final Future<Void> result = Future.future();
try {
int deviceCount = 0;
final JsonArray allObjects = deviceIdentities.toJsonArray();
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
deviceCount += addDevicesForTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} device identities from file [{}]", deviceCount, getConfig().getFilename());
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from device identity file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
}
代码示例来源:origin: org.eclipse.hono/hono-service-device-registry
private Future<Void> addAll(final Buffer deviceIdentities) {
final Future<Void> result = Future.future();
try {
int deviceCount = 0;
final JsonArray allObjects = deviceIdentities.toJsonArray();
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
deviceCount += addDevicesForTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} device identities from file [{}]", deviceCount, getConfig().getFilename());
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from device identity file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
}
代码示例来源:origin: eclipse/hono
private Future<Void> addAll(final Buffer credentials) {
final Future<Void> result = Future.future();
try {
int credentialsCount = 0;
final JsonArray allObjects = credentials.toJsonArray();
log.debug("trying to load credentials for {} tenants", allObjects.size());
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
credentialsCount += addCredentialsForTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} credentials from file [{}]", credentialsCount, getConfig().getFilename());
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from credentials file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
};
代码示例来源:origin: org.eclipse.hono/hono-service-device-registry
private Future<Void> addAll(final Buffer credentials) {
final Future<Void> result = Future.future();
try {
int credentialsCount = 0;
final JsonArray allObjects = credentials.toJsonArray();
log.debug("trying to load credentials for {} tenants", allObjects.size());
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
credentialsCount += addCredentialsForTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} credentials from file [{}]", credentialsCount, getConfig().getFilename());
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from credentials file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
};
代码示例来源:origin: eclipse/hono
private Future<Void> addAll(final Buffer tenantsBuffer) {
final Future<Void> result = Future.future();
try {
if (tenantsBuffer.length() > 0) {
int tenantCount = 0;
final JsonArray allObjects = tenantsBuffer.toJsonArray();
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
tenantCount++;
addTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} tenants from file [{}]", tenantCount, getConfig().getFilename());
}
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from tenants file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
}
代码示例来源:origin: org.eclipse.hono/hono-service-device-registry
private Future<Void> addAll(final Buffer tenantsBuffer) {
final Future<Void> result = Future.future();
try {
if (tenantsBuffer.length() > 0) {
int tenantCount = 0;
final JsonArray allObjects = tenantsBuffer.toJsonArray();
for (final Object obj : allObjects) {
if (JsonObject.class.isInstance(obj)) {
tenantCount++;
addTenant((JsonObject) obj);
}
}
log.info("successfully loaded {} tenants from file [{}]", tenantCount, getConfig().getFilename());
}
result.complete();
} catch (final DecodeException e) {
log.warn("cannot read malformed JSON from tenants file [{}]", getConfig().getFilename());
result.fail(e);
}
return result;
}
代码示例来源:origin: burrsutter/vertx-game-server
final JsonArray achievementResponse = body.toJsonArray();
int size = achievementResponse.size();
final JsonObject achievements = new JsonObject();
代码示例来源:origin: io.vertx/vertx-web-client
@Test
public void testSendJsonArrayBody() throws Exception {
JsonArray body = new JsonArray().add(0).add(1).add(2);
testSendBody(body, (contentType, buff) -> {
assertEquals("application/json", contentType);
assertEquals(body, buff.toJsonArray());
});
}
内容来源于网络,如有侵权,请联系作者删除!