本文整理汇总了Java中io.vertx.core.json.JsonObject.remove方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.remove方法的具体用法?Java JsonObject.remove怎么用?Java JsonObject.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cannotCreateALoanWithoutAction
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void cannotCreateALoanWithoutAction()
throws MalformedURLException,
InterruptedException,
ExecutionException,
TimeoutException {
JsonObject loanRequest = new LoanRequestBuilder().create();
loanRequest.remove("action");
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture();
client.post(loanStorageUrl(), loanRequest, StorageTestSuite.TENANT_ID,
ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Creating the loan should fail: %s", response.getBody()),
response.getStatusCode(), is(UNPROCESSABLE_ENTITY));
}
示例2: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static void fromJson(final JsonObject json, final ServidorOptions obj) {
if (json.getValue("name") instanceof String) {
obj.setName(json.getString("name"));
}
if (json.getValue("config") instanceof JsonObject) {
final JsonObject config = json.getJsonObject("config").copy();
if (config.getValue("host") instanceof String) {
obj.setHost(config.getString("host"));
}
if (config.getValue("port") instanceof Integer) {
obj.setPort(config.getInteger("port"));
}
config.remove("host");
config.remove("port");
obj.setOptions(config);
}
}
示例3: createDatabase
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private static DB createDatabase(JsonObject config) {
config.put("user", "root");
config.remove("password");
try {
DB db = DB.newEmbeddedDB(3366);
db.start();
return db;
} catch (ManagedProcessException e) {
LOG.debug("DB startup failed", e);
throw new RuntimeException(e.getCause());
}
}
示例4: consume
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Middle process
*
* @param request
* @param type
*/
public static IpcData consume(final IpcRequest request, final IpcType type) {
final IpcData ipcData = new IpcData();
final IpcEnvelop envelop = request.getEnvelop();
final String data = envelop.getBody();
final JsonObject json = new JsonObject(data);
// Address convert
if (json.containsKey("address")) {
ipcData.setAddress(json.getString("address"));
json.remove("address");
}
ipcData.setData(Buffer.buffer(data));
ipcData.setType(type);
return ipcData;
}
示例5: importES
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private static void importES(Client client) throws IOException {
String filePath = "es.txt";
File file = new File(filePath);
if (!file.exists()) {
System.out.println("文件不存在");
return;
}
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
//读取刚才导出的ES数据
String string;
int count = 0;
//开启批量插入
BulkRequestBuilder bulkRequest = client.prepareBulk();
while ((string = br.readLine()) != null) {
if (Objects.equals(string, "")) continue;
JsonObject jsonObject = new JsonObject(string);
System.out.println(jsonObject);
String ESindex;
if (jsonObject.containsKey("ESindex")) {
ESindex = (String) jsonObject.remove("ESindex");
} else {
ESindex = index;
}
String EStype;
if (jsonObject.containsKey("EStype")) {
EStype = (String) jsonObject.remove("EStype");
} else {
EStype = type;
}
++count;
bulkRequest.add(client.prepareIndex(ESindex, EStype, String.valueOf(count)).setSource(jsonObject.toString()));
//每一千条提交一次
if (count % 1000 == 0) {
bulkRequest.execute().actionGet();
System.out.println("提交了:" + count);
}
}
bulkRequest.execute().actionGet();
System.out.println("插入完毕");
}
}