本文整理匯總了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("插入完畢");
}
}