當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。