当前位置: 首页>>代码示例>>Java>>正文


Java JsonObjectBuilder类代码示例

本文整理汇总了Java中javax.json.JsonObjectBuilder的典型用法代码示例。如果您正苦于以下问题:Java JsonObjectBuilder类的具体用法?Java JsonObjectBuilder怎么用?Java JsonObjectBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonObjectBuilder类属于javax.json包,在下文中一共展示了JsonObjectBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setProperties

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Override
protected void setProperties() {
	final DirectoryNode dirNode = (DirectoryNode)entry;

	final JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
	ClassID storageClsid = dirNode.getStorageClsid();
	if (storageClsid == null) {
		jsonBuilder.addNull("storage_clsid");
	} else {
		jsonBuilder.add("storage_clsid", storageClsid.toString());
	}
	
	dirNode.forEach(e -> {
		if (e instanceof DocumentNode) {
			DocumentNode dn = (DocumentNode)e;
			jsonBuilder.add(escapeString(dn.getName()), "Size: "+dn.getSize());
		}
	});
	
	final String props = jsonBuilder.build().toString();
	if (surrugateEntry != null) {
		treeObservable.mergeProperties(props);
	} else {
		treeObservable.setProperties(props);
	}
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:27,代码来源:OLEDirEntry.java

示例2: onOpen

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@OnOpen
public void onOpen(Session session, @PathParam("uuid") String uuid) {
    UUID key = UUID.fromString(uuid);
    peers.put(key, session);
    JsonArrayBuilder builder = Json.createArrayBuilder();
    for (StatusEventType statusEventType : StatusEventType.values()) {
        JsonObjectBuilder object = Json.createObjectBuilder();
        builder.add(object.add(statusEventType.name(), statusEventType.getMessage()).build());
    }

    RemoteEndpoint.Async asyncRemote = session.getAsyncRemote();
    asyncRemote.sendText(builder.build().toString());
    // Send pending messages
    List<String> messages = messageBuffer.remove(key);
    if (messages != null) {
        messages.forEach(asyncRemote::sendText);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:19,代码来源:MissionControlStatusEndpoint.java

示例3: buildPostRunResponse

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
Response buildPostRunResponse(OccasionResponse occasionResponse) {

    Throwable notificationThrowable = occasionResponse.getNotificationThrowable();
    String requestResponse = occasionResponse.getNotificationType();
    if (notificationThrowable != null) {
      logger.fine("Throwable message: " + notificationThrowable.getMessage());
    }
    JsonBuilderFactory factory = Json.createBuilderFactory(null);
    JsonObjectBuilder builder = factory.createObjectBuilder();
    JsonObject responseBody = null;
    if (requestResponse.equals(OccasionResponse.NOTIFICATION_TYPE_LOG)
        || requestResponse.equals(OccasionResponse.NOTIFICATION_TYPE_TWEET)) {
      responseBody = builder.add(JSON_KEY_OCCASION_POST_RUN_SUCCESS, requestResponse).build();
    } else {
      responseBody = builder.add(JSON_KEY_OCCASION_POST_RUN_ERROR, requestResponse).build();
    }
    return Response.ok(responseBody, MediaType.APPLICATION_JSON).build();
  }
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:19,代码来源:OccasionResource.java

示例4: uploadPart

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
/**
 *  Add a segment of a binary.
 *
 *  <p>Note: the response will be a json structure, such as:</p>
 *  <pre>{
 *    "digest": "a-hash"
 *  }</pre>
 *
 *  @param id the upload session identifier
 *  @param partNumber the part number
 *  @param part the input stream
 *  @return a response
 */
@PUT
@Timed
@Path("{partNumber}")
@Produces("application/json")
public String uploadPart(@PathParam("id") final String id,
        @PathParam("partNumber") final Integer partNumber,
        final InputStream part) {

    final JsonObjectBuilder builder = Json.createObjectBuilder();

    if (!binaryService.uploadSessionExists(id)) {
        throw new NotFoundException();
    }

    final String digest = binaryService.uploadPart(id, partNumber, part);

    return builder.add("digest", digest).build().toString();
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:32,代码来源:MultipartUploader.java

示例5: addValue

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
public static void addValue(JsonObjectBuilder obj, String key, Object value) {
    if (value instanceof Integer) {
        obj.add(key, (Integer)value);
    }
    else if (value instanceof String) {
        obj.add(key, (String)value);
    }
    else if (value instanceof Float) {
        obj.add(key, (Float)value);
    }
    else if (value instanceof Double) {
        obj.add(key, (Double)value);
    }
    else if (value instanceof Boolean) {
        obj.add(key, (Boolean)value);
    }
    else if (value instanceof JsonValue) {
        JsonValue val = (JsonValue)value;
        obj.add(key, val);
    }
    // Add more cases here
}
 
开发者ID:Fiware,项目名称:NGSI-LD_Wrapper,代码行数:23,代码来源:JsonUtilities.java

示例6: getMeta

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
/**
 * Develops meta json object. See developResult() above for details.
 * <p>
 * Sample output: {"totalTests": 1, "lastTest":true}} where; totalTests would be part of the first
 * result while lastTest would be part of the last result from the batch.
 *
 * @return JsonObjectBuilder
 */
private JsonObjectBuilder getMeta(boolean withBrowserList) {
  JsonObjectBuilder jsonObjectBuilder = null;

  if (this.isFirstTest()) {
    if (jsonObjectBuilder == null)
      jsonObjectBuilder = Json.createObjectBuilder();
    jsonObjectBuilder.add("totalTests", this.totalTests);
    if (withBrowserList)
      jsonObjectBuilder.add("browsers", Configurator.getInstance().getBrowserListJsonArray())
              .add("description",this.testConf.getDescription());
  }

  if (this.isLastTest) {
    if (jsonObjectBuilder == null)
      jsonObjectBuilder = Json.createObjectBuilder();
    jsonObjectBuilder.add("lastTest", this.isLastTest);
  }

  return jsonObjectBuilder;
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:29,代码来源:TestManager.java

示例7: getJsonObjectBuilder

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Override
public JsonObjectBuilder getJsonObjectBuilder() {
    JsonObjectBuilder jsonObjectBuilder =
            Json.createObjectBuilder()
                    .add("trackIdentifier", this.trackIdentifier)
                    .add("remoteSource", this.remoteSource)
                    .add("ended", this.ended)
                    .add("detached", this.detached)
                    .add("frameWidth", this.frameWidth)
                    .add("frameHeight", this.frameHeight)
                    .add("framesPerSecond", this.framesPerSecond)
                    .add("framesSent", this.framesSent)
                    .add("framesReceived", this.framesReceived)
                    .add("frameHeight", this.frameHeight)
                    .add("framesDecoded", this.framesDecoded)
                    .add("framesDropped", this.framesDropped)
                    .add("framesCorrupted", this.framesCorrupted)
                    .add("audioLevel", this.audioLevel);

    return jsonObjectBuilder;
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:22,代码来源:RTCMediaStreamTrackStats.java

示例8: getJsonObjectBuilder

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Override
public JsonObjectBuilder getJsonObjectBuilder() {
    JsonObjectBuilder jsonObjectBuilder =
            Json.createObjectBuilder()
                    .add("ssrc", this.ssrc)
                    .add("mediaType", this.mediaType)
                    .add("trackId", this.trackId)
                    .add("transportId", this.transportId)
                    .add("nackCount", this.nackCount)
                    .add("codecId", this.codecId);
    if (this.inbound)
        jsonObjectBuilder.add("packetsReceived", Utility.getStatByName(this.statObject, "packetsReceived"))
                .add("bytesReceived", Utility.getStatByName(this.statObject, "bytesReceived"))
                .add("packetsLost", Utility.getStatByName(this.statObject, "packetsLost"))
                .add("packetsDiscarded", Utility.getStatByName(this.statObject, "packetsDiscarded"))
                .add("jitter", Utility.getStatByName(this.statObject, "jitter"))
                .add("remoteId", Utility.getStatByName(this.statObject, "remoteId"))
                .add("framesDecoded", Utility.getStatByName(this.statObject, "framesDecoded"));
    else
        jsonObjectBuilder.add("packetsSent", Utility.getStatByName(this.statObject, "packetsSent"))
                .add("bytesSent", Utility.getStatByName(this.statObject, "bytesSent"))
                .add("remoteId", Utility.getStatByName(this.statObject, "remoteId"))
                .add("framesDecoded", Utility.getStatByName(this.statObject, "framesDecoded"));

    return jsonObjectBuilder;
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:27,代码来源:RTCRTPStreamStats.java

示例9: getJsonObjectBuilder

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Override
public JsonObjectBuilder getJsonObjectBuilder() {
    JsonObjectBuilder jsonObjectBuilder =
            Json.createObjectBuilder()
                    .add("transportId", this.transportId)
                    .add("localCandidateId", this.localCandidateId)
                    .add("remoteCandidateId", this.remoteCandidateId)
                    .add("state", this.state)
                    .add("priority", this.priority)
                    .add("nominated", this.nominated)
                    .add("bytesSent", this.bytesSent)
                    .add("currentRoundTripTime", this.currentRoundTripTime)
                    .add("totalRoundTripTime", this.totalRoundTripTime)
                    .add("bytesReceived", this.bytesReceived);
    return jsonObjectBuilder;
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:17,代码来源:RTCIceCandidatePairStats.java

示例10: testScript

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Override
public Object testScript() throws Exception {
    String result = "";
    webDriver = this.getWebDriverList().get(0);
    JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
    for (String target: subjectList.keySet()){
        subject = target;
        this.takeAction();
        result = this.testJavaScript();
        subjectList.replace(target,result);
        jsonObjectBuilder.add(target, result);
    }
    JsonObject payload = jsonObjectBuilder.build();
    if (logger.isInfoEnabled())
      logger.info(payload.toString());
    return payload.toString();
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:18,代码来源:GetUpdateTest.java

示例11: makeNotificationConnection

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
@Retry(maxRetries = 2)
@Fallback(NotificationFallbackHandler.class)
public OccasionResponse makeNotificationConnection(
    String message,
    Orchestrator orchestrator,
    String jwtTokenString,
    String notification11ServiceUrl,
    String twitterHandle,
    String notificationServiceUrl)
    throws IOException {

  JsonBuilderFactory factory = Json.createBuilderFactory(null);
  JsonObjectBuilder builder = factory.createObjectBuilder();
  JsonObject notificationRequestPayload = builder.add(JSON_KEY_NOTIFICATION, message).build();
  Response notificationResponse =
      orchestrator.makeConnection(
          "POST", notificationServiceUrl, notificationRequestPayload.toString(), jwtTokenString);
  OccasionResponse occasionResponse =
      new OccasionResponse(notificationResponse, OccasionResponse.NOTIFICATION_TYPE_LOG, null);

  return occasionResponse;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:23,代码来源:NotificationRetryBean.java

示例12: buildGroupResponseObject

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
private String buildGroupResponseObject(String name, String[] members, String[] occasions) {
  JsonObjectBuilder group = Json.createObjectBuilder();
  group.add(JSON_KEY_GROUP_NAME, name);

  JsonArrayBuilder membersArray = Json.createArrayBuilder();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.add(JSON_KEY_MEMBERS_LIST, membersArray.build());

  JsonArrayBuilder occasionsArray = Json.createArrayBuilder();
  for (int i = 0; i < occasions.length; i++) {
    occasionsArray.add(occasions[i]);
  }
  group.add(JSON_KEY_OCCASIONS_LIST, occasionsArray.build());

  return group.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:19,代码来源:OrchestratorResourceMockTest.java

示例13: buildUserResponseObject

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
private String buildUserResponseObject(
    String firstName,
    String lastName,
    String userName,
    String twitterHandle,
    String wishListLink,
    String[] groups) {
  JsonObjectBuilder user = Json.createObjectBuilder();
  user.add(JSON_KEY_USER_FIRST_NAME, firstName);
  user.add(JSON_KEY_USER_LAST_NAME, lastName);
  user.add(JSON_KEY_USER_NAME, userName);
  user.add(JSON_KEY_USER_TWITTER_HANDLE, twitterHandle);
  user.add(JSON_KEY_USER_WISH_LIST_LINK, wishListLink);

  JsonArrayBuilder groupArray = Json.createArrayBuilder();
  for (int i = 0; i < groups.length; i++) {
    groupArray.add(groups[i]);
  }
  user.add(JSON_KEY_USER_GROUPS, groupArray.build());

  return user.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:23,代码来源:OrchestratorResourceMockTest.java

示例14: getJson

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
/**
 * Create a JSON string based on the content of this group
 *
 * @return - A JSON string with the content of this group
 */
public String getJson() {
  JsonObjectBuilder group = Json.createObjectBuilder();
  group.add(JSON_KEY_GROUP_ID, id);
  group.add(JSON_KEY_GROUP_NAME, name);

  JsonArrayBuilder membersArray = Json.createArrayBuilder();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.add(JSON_KEY_MEMBERS_LIST, membersArray.build());

  return group.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:19,代码来源:Group.java

示例15: getJson

import javax.json.JsonObjectBuilder; //导入依赖的package包/类
/**
 * Create a JSON string based on the content of this group
 *
 * @return The JSON string with the content of this group
 */
public String getJson() {
  JsonObjectBuilder group = Json.createObjectBuilder();
  if (id != null) {
    group.add(JSON_KEY_GROUP_ID, id);
  }

  group.add(JSON_KEY_GROUP_NAME, name);

  JsonArrayBuilder membersArray = Json.createArrayBuilder();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.add(JSON_KEY_MEMBERS_LIST, membersArray.build());

  return group.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:22,代码来源:Group.java


注:本文中的javax.json.JsonObjectBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。