com.eclipsesource.json.JsonObject.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.eclipsesource.json.JsonObject.<init>()方法的一些代码示例,展示了JsonObject.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.<init>()方法的具体详情如下:
包路径:com.eclipsesource.json.JsonObject
类名称:JsonObject
方法名:<init>

JsonObject.<init>介绍

[英]Creates a new empty JsonObject.
[中]创建一个新的空JsonObject。

代码示例

代码示例来源:origin: ralfstx/minimal-json

/**
 * Creates a new empty JsonObject. This is equivalent to creating a new JsonObject using the
 * constructor.
 *
 * @return a new empty JSON object
 */
public static JsonObject object() {
 return new JsonObject();
}

代码示例来源:origin: ralfstx/minimal-json

@Override
public JsonObject startObject() {
 return new JsonObject();
}

代码示例来源:origin: ralfstx/minimal-json

JsonObject getResults() {
 return new JsonObject(results);
}

代码示例来源:origin: ralfstx/minimal-json

/**
 * Returns an unmodifiable JsonObject for the specified one. This method allows to provide
 * read-only access to a JsonObject.
 * <p>
 * The returned JsonObject is backed by the given object and reflect changes that happen to it.
 * Attempts to modify the returned JsonObject result in an
 * <code>UnsupportedOperationException</code>.
 * </p>
 *
 * @param object
 *          the JsonObject for which an unmodifiable JsonObject is to be returned
 * @return an unmodifiable view of the specified JsonObject
 */
public static JsonObject unmodifiableObject(JsonObject object) {
 return new JsonObject(object, true);
}

代码示例来源:origin: ralfstx/minimal-json

@Override
protected void setUp() throws IOException {
 jsonObject = new JsonObject();
 for (int index = 0; index < size; index++) {
  String name = Integer.toHexString(index);
  jsonObject.add(name, index);
 }
}

代码示例来源:origin: ralfstx/minimal-json

private static JsonObject transformResults(JsonObject caliperResults) {
 return new JsonObject().add("name", extractSimpleName(caliperResults))
             .add("details", extractEnvironment(caliperResults))
             .add("measurements", extractMeasurements(caliperResults));
}

代码示例来源:origin: com.eclipsesource.minimal-json/minimal-json

/**
 * Creates a new empty JsonObject. This is equivalent to creating a new JsonObject using the
 * constructor.
 *
 * @return a new empty JSON object
 */
public static JsonObject object() {
 return new JsonObject();
}

代码示例来源:origin: ralfstx/minimal-json

private static JsonObject extractMeasurement(JsonObject measurement) {
 JsonObject times = measurement.get("v").asObject()
                .get("measurementSetMap").asObject()
                .get("TIME").asObject();
 return new JsonObject().add("variables", measurement.get("k").asObject().get("variables"))
             .add("units", times.get("unitNames"))
             .add("values", extractTimes(times.get("measurements").asArray()));
}

代码示例来源:origin: Netflix/spectator

private JsonObject toJson(Map<String, String> tags) {
 final JsonObject obj = new JsonObject();
 for (Map.Entry<String, String> entry : tags.entrySet()) {
  obj.add(entry.getKey(), entry.getValue());
 }
 return obj;
}

代码示例来源:origin: box/box-android-sdk

/**
 * Constructs an empty BoxJSONObject.
 */
public BoxJsonObject() {
  createFromJson(new JsonObject());
}

代码示例来源:origin: box/box-java-sdk

/**
 * Creates a new metadata with the specified scope and template.
 * @param scope the scope of the metadata.
 * @param template  the template of the metadata.
 */
public Metadata(String scope, String template) {
  JsonObject object = new JsonObject()
      .add("$scope", scope)
      .add("$template", template);
  this.values = object;
}

代码示例来源:origin: box/box-java-sdk

/**
 * Assigns retention policy with givenID to the enterprise.
 * @param api the API connection to be used by the created assignment.
 * @param policyID id of the assigned retention policy.
 * @return info about created assignment.
 */
public static BoxRetentionPolicyAssignment.Info createAssignmentToEnterprise(BoxAPIConnection api,
                                       String policyID) {
  return createAssignment(api, policyID, new JsonObject().add("type", TYPE_ENTERPRISE), null);
}

代码示例来源:origin: org.eclipse.ditto/ditto-json

@Override
protected String createStringRepresentation() {
  final com.eclipsesource.json.JsonObject minJsonObject = new com.eclipsesource.json.JsonObject();
  fields.values().forEach(field -> minJsonObject.add(field.getKeyName(), JsonFactory.convert(field.getValue())));
  return minJsonObject.toString();
}

代码示例来源:origin: samczsun/Skype4J

protected JsonObject buildSubscriptionObject() {
  JsonObject subscriptionObject = new JsonObject();
  subscriptionObject.add("channelType", "httpLongPoll");
  subscriptionObject.add("template", "raw");
  JsonArray interestedResources = new JsonArray();
  this.resources.forEach(interestedResources::add);
  subscriptionObject.add("interestedResources", interestedResources);
  return subscriptionObject;
}

代码示例来源:origin: samczsun/Skype4J

private void sendImage(byte[] data, String imageName) throws ConnectionException, IOException {
  String id = Utils.uploadImage(data, Utils.ImageType.IMGT1, this);
  long ms = System.currentTimeMillis();
  String content = "<URIObject type=\"Picture.1\" uri=\"https://api.asm.skype.com/v1/objects/%s\" url_thumbnail=\"https://api.asm.skype.com/v1/objects/%s/views/imgt1\">MyLegacy pish <a href=\"https://api.asm.skype.com/s/i?%s\">https://api.asm.skype.com/s/i?%s</a><Title/><Description/><OriginalName v=\"%s\"/><meta type=\"photo\" originalName=\"%s\"/></URIObject>";
  content = String.format(content, id, id, id, id, imageName, imageName);
  JsonObject obj = new JsonObject();
  obj.add("content", content);
  obj.add("messagetype", "RichText/UriObject");
  obj.add("contenttype", "text");
  obj.add("clientmessageid", String.valueOf(ms));
  Endpoints.SEND_MESSAGE_URL.open(getClient(), getIdentity()).expect(201, "While sending message").post(obj);
}

代码示例来源:origin: samczsun/Skype4J

@Override
public void sendContact(Contact contact) throws ConnectionException {
  long ms = System.currentTimeMillis();
  JsonObject obj = new JsonObject();
  obj.add("content", String.format("<contacts><c t=\"s\" s=\"%s\" f=\"%s\"/></contacts>", contact.getUsername(),
      contact.getDisplayName()));
  obj.add("messagetype", "RichText/Contacts");
  obj.add("contenttype", "text");
  obj.add("clientmessageid", String.valueOf(ms));
  Endpoints.SEND_MESSAGE_URL.open(getClient(), getIdentity()).expect(201, "While sending message").post(obj);
}

代码示例来源:origin: box/box-java-sdk

private BoxCollaboration.Info collaborate(JsonObject accessibleByField, BoxCollaboration.Role role,
                     Boolean notify, Boolean canViewPath) {
  JsonObject itemField = new JsonObject();
  itemField.add("id", this.getID());
  itemField.add("type", "file");
  return BoxCollaboration.create(this.getAPI(), accessibleByField, itemField, role, notify, canViewPath);
}

代码示例来源:origin: samczsun/Skype4J

@Override
public GroupChat joinChat(String id) throws ConnectionException, ChatNotFoundException, NoPermissionException {
  Validate.isTrue(id.startsWith("19:") && id.endsWith("@thread.skype"), "Invalid chat id");
  JsonObject obj = new JsonObject();
  obj.add("role", "User");
  Endpoints.ADD_MEMBER_URL.open(this, id, getUsername()).on(403, (connection) -> {
    throw new NoPermissionException();
  }).on(404, (connection) -> {
    throw new ChatNotFoundException();
  }).expect(200, "While joining chat").put(obj);
  return (GroupChat) getOrLoadChat(id);
}

代码示例来源:origin: org.eclipse.leshan/leshan-server-cluster

@Override
public void updated(RegistrationUpdate update, Registration updatedRegistration,
    Registration previousRegistration) {
  JsonObject value = new JsonObject();
  value.add("regUpdate", RegistrationUpdateSerDes.jSerialize(update));
  value.add("regUpdated", RegistrationSerDes.jSerialize(updatedRegistration));
  try (Jedis j = pool.getResource()) {
    j.publish(UPDATE_EVENT, value.toString());
  }
}

代码示例来源:origin: samczsun/Skype4J

@Override
public void setRole(Participant.Role role) throws ConnectionException, NoPermissionException {
  if (!(getChat() instanceof GroupChat)) throw new NoPermissionException();
  Endpoints.MODIFY_MEMBER_URL.open(getClient(), getChat().getIdentity(), getId()).on(400, (connection) -> {
    throw new NoPermissionException();
  }).expect(200, "While updating role").put(new JsonObject().add("role", role.name().toLowerCase()));
  updateRole(role);
}

相关文章