本文整理匯總了Java中io.vertx.core.json.JsonObject.encode方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonObject.encode方法的具體用法?Java JsonObject.encode怎麽用?Java JsonObject.encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.encode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeToWire
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
@Override
public void encodeToWire(Buffer buffer, AuthInfo s) {
// Easiest ways is using JSON object
JsonObject jsonToEncode = new JsonObject();
jsonToEncode.put("serverName", s.serverName);
jsonToEncode.put("sessionToken", s.sessionToken);
// Encode object to string
String jsonToStr = jsonToEncode.encode();
// Length of JSON: is NOT characters count
int length = jsonToStr.getBytes().length;
// Write data into given buffer
buffer.appendInt(length);
buffer.appendString(jsonToStr);
}
示例2: checkForDuplicate
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
/**
* Actual routine that check for "duplication". Could be anything, depending on use case.
* The future fails when a duplicate is found and succeeds when it is not.
* This allows for async execution
*
* @see net.wissel.salesforce.vertx.dedup.AbstractSFDCDedupVerticle#checkForDuplicate(io.vertx.core.Future, io.vertx.core.json.JsonObject)
*/
@Override
protected void checkForDuplicate(final Future<Void> failIfDuplicate, final JsonObject messageBody) {
final String candidate = messageBody.encode();
if (this.memoryQueue.contains(candidate)) {
// We have a duplicate and fail the future
failIfDuplicate.fail("Duplicate");
} else {
this.memoryQueue.offer(candidate);
// Limit the size of the queue
while (this.memoryQueue.size() > MAX_MEMBERS) {
this.memoryQueue.poll();
}
failIfDuplicate.complete();
}
}
示例3: RequiredFieldException
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public RequiredFieldException(final Class<?> clazz,
final JsonObject data,
final String field) {
super(clazz, data.encode(), field);
}
示例4: ForbiddenFieldException
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public ForbiddenFieldException(final Class<?> clazz,
final JsonObject data,
final String field) {
super(clazz, data.encode(), field);
}
示例5: to
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
@Override
public String to(JsonObject userObject) {
return userObject==null?null:userObject.encode();
}
示例6: retrieveSDKAsJSON
import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public String retrieveSDKAsJSON(boolean pretty) {
JsonObject json = JsonObject.mapFrom(retrieveSDK());
return (pretty) ? json.encodePrettily() : json.encode();
}