@Override public User signUp() { final JsonArray registered = this.server.storage().build() .getJsonArray("users"); final JsonArrayBuilder users = Json.createArrayBuilder(); for(final JsonValue user: registered) { users.add(user); } users.add( Json.createObjectBuilder() .add( this.json.getString("username"), this.json ) ); this.server.storage().add("users", users.build()); return new MkUser(this.server, this.json.getString("username")); }
@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); } }
private JsonArray readMessages(JsonReader reader) throws Exception { JsonArrayBuilder b = Json.createArrayBuilder(); JsonObject obj; try{ obj = reader.readObject(); } finally { reader.close(); } obj.entrySet().forEach(e -> { Message msg=new Message(); JsonObject m; m = msg.generate(e.getValue().toString(), "@id", "http://inbox.rerum.io/id/" + e.getKey() + ""); if(MOTIVATION.length()==0 || MOTIVATION.contains(m.getJsonString("motivation").toString())){ b.add(m); } }); JsonArray messages = b.build(); return messages; }
/** * This method adds teams of the specified page to the teams array. * * @param arrBuilder specifies the array builder to add the teams into. * @param year specifies the optional year, null for all years. * @param pageNum specifies the page number. * @param verbosity specifies optional verbosity, null for full verbosity. * @param statusOut specifies standard output stream for command status, can be null for quiet mode. * @return true if successful, false if failed. */ private boolean addTeams( JsonArrayBuilder arrBuilder, String year, int pageNum, String verbosity, PrintStream statusOut) { String request = "teams/"; if (year != null) request += year + "/"; request += pageNum; if (verbosity != null) request += "/" + verbosity; JsonStructure data = get(request, statusOut, header); boolean success; if (data != null && data.getValueType() == JsonValue.ValueType.ARRAY && !((JsonArray)data).isEmpty()) { for (JsonValue team: (JsonArray)data) { arrBuilder.add(team); } success = true; } else { success = false; } return success; }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = contactService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getContactId()) .add("name", h.getValue()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = guardianService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getGuardianId()) .add("name", h.getParentID().getFirstName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = scheduleService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getSchedule()) .add("name", "expand") .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = cityService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getCityId()) .add("name", h.getCityName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = genderService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getGenderId()) .add("value", h.getGenderName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = receptionistService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getReceptionistId()) .add("name", h.getPersonId().getFirstName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = adminClinicService.get().stream().map(h -> Json.createObjectBuilder() .add("firstname", h.getPersonId().getFirstName()) .add("lastname", h.getPersonId().getLastName()) .add("id", h.getAdminClinicId()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = countryService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getCountryId()) .add("name", h.getCountryName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = religionService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getReligionId()) .add("name", h.getName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = addressService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getAddressId()) .add("name", h.getStreetName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { List<Nurse> get = nurseService.get(); List<Nurse> collect = get.stream().collect(Collectors.toList()); build = collect.stream().map(h -> Json.createObjectBuilder() .add("firstname", h.getPersonId().getFirstName()) .add("lastname", h.getPersonId().getLastName()) .add("id", h.getNurseId()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = personService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getPersonId()) .add("name", h.getFirstName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = martialStatusService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getMartialStatusId()) .add("name", h.getMartialStatusName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = pharmacistService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getPharmacistId()) .add("name", h.getPersonId().getFirstName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("find") @Produces(MediaType.APPLICATION_JSON) public Response find() { JsonArray build = null; try { build = personArchiveService.get().stream().map(h -> Json.createObjectBuilder() .add("id", h.getPersonArchiveId()) .add("name", h.getFirstName()) .build()) .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add) .build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
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(); }
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(); }
/** * 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(); }
private void getContacts(HttpServletRequest req, HttpServletResponse resp) { resp.setContentType("application/json"); try { JsonArrayBuilder jarray = Json.createArrayBuilder(); for (Entry<String, Contact> contactEntry : contacts.entrySet()) { JsonObjectBuilder jobject = contactEntry.getValue().getJsonObjectBuilder(); jobject.add("id", Integer.parseInt(contactEntry.getKey())); jarray.add(jobject); } StringWriter sw = new StringWriter(); Json.createWriter(sw).writeArray(jarray.build()); String json = sw.toString(); resp.setContentLength(json.length()); resp.getWriter().write(json); } catch (IOException e) { } }
private JsonArrayBuilder createArray(TypeInstanceProperty tip) { JsonArrayBuilder builder = Json.createArrayBuilder(); for (TypeInstance instance : tip.values()) { if (isObject(instance)) { builder.add(createObject(instance)); } else if (isArray(instance)) { builder.add(createArray(instance)); } else { addScalarOrNull(builder, instance); } } return builder; }
private JsonObjectBuilder getContentInSolrButNotDatabase() throws SearchException { List<Long> dataversesInSolrOnly = indexService.findDataversesInSolrOnly(); List<Long> datasetsInSolrOnly = indexService.findDatasetsInSolrOnly(); JsonArrayBuilder dataversesInSolrButNotDatabase = Json.createArrayBuilder(); for (Long dataverseId : dataversesInSolrOnly) { dataversesInSolrButNotDatabase.add(dataverseId); } JsonArrayBuilder datasetsInSolrButNotDatabase = Json.createArrayBuilder(); for (Long datasetId : datasetsInSolrOnly) { datasetsInSolrButNotDatabase.add(datasetId); } JsonObjectBuilder contentInSolrButNotDatabase = Json.createObjectBuilder() /** * @todo What about files? Currently files are always indexed * along with their parent dataset */ .add("dataverses", dataversesInSolrButNotDatabase.build().size()) .add("datasets", datasetsInSolrButNotDatabase.build().size()); return contentInSolrButNotDatabase; }
private JsonObjectBuilder toJson(SavedSearch savedSearch) { JsonObjectBuilder savedSearchJson = Json.createObjectBuilder(); long savedSearchId = savedSearch.getId(); Dataverse definitionPoint = savedSearch.getDefinitionPoint(); JsonArrayBuilder fqBuilder = Json.createArrayBuilder(); for (SavedSearchFilterQuery fq : savedSearch.getSavedSearchFilterQueries()) { fqBuilder.add(fq.getFilterQuery()); } savedSearchJson.add("query", savedSearch.getQuery()); savedSearchJson.add("filterQueries", fqBuilder); savedSearchJson.add("id", savedSearchId); savedSearchJson.add("definitionPointId", definitionPoint.getId()); savedSearchJson.add("definitionPointAlias", definitionPoint.getAlias()); savedSearchJson.add("creatorId", savedSearch.getCreator().getId()); return savedSearchJson; }
@GET @Path("{id}/links") public Response getLinks(@PathParam("id") long idSupplied, @QueryParam("key") String apiKey) { try { AuthenticatedUser u = findUserOrDie(apiKey); if (!u.isSuperuser()) { return errorResponse(Response.Status.FORBIDDEN, "Not a superuser"); } Dataset dataset = findDatasetOrDie(idSupplied); long datasetId = dataset.getId(); List<Dataverse> dvsThatLinkToThisDatasetId = dataverseSvc.findDataversesThatLinkToThisDatasetId(datasetId); JsonArrayBuilder dataversesThatLinkToThisDatasetIdBuilder = Json.createArrayBuilder(); for (Dataverse dataverse : dvsThatLinkToThisDatasetId) { dataversesThatLinkToThisDatasetIdBuilder.add(dataverse.getAlias() + " (id " + dataverse.getId() + ")"); } JsonObjectBuilder response = Json.createObjectBuilder(); response.add("dataverses that link to dataset id " + datasetId, dataversesThatLinkToThisDatasetIdBuilder); return okResponse(response); } catch (WrappedResponse wr) { return wr.getResponse(); } }
public JsonObjectBuilder indexAllOrSubsetPreview(long numPartitions, long partitionId, boolean skipIndexed) { JsonObjectBuilder response = Json.createObjectBuilder(); JsonObjectBuilder previewOfWorkload = Json.createObjectBuilder(); JsonObjectBuilder dvContainerIds = Json.createObjectBuilder(); JsonArrayBuilder dataverseIds = Json.createArrayBuilder(); List<Dataverse> dataverses = dataverseService.findAllOrSubset(numPartitions, partitionId, skipIndexed); for (Dataverse dataverse : dataverses) { dataverseIds.add(dataverse.getId()); } JsonArrayBuilder datasetIds = Json.createArrayBuilder(); List<Dataset> datasets = datasetService.findAllOrSubset(numPartitions, partitionId, skipIndexed); for (Dataset dataset : datasets) { datasetIds.add(dataset.getId()); } dvContainerIds.add("dataverses", dataverseIds); dvContainerIds.add("datasets", datasetIds); previewOfWorkload.add("dvContainerIds", dvContainerIds); previewOfWorkload.add("dataverseCount", dataverses.size()); previewOfWorkload.add("datasetCount", datasets.size()); previewOfWorkload.add("partitionId", partitionId); response.add("previewOfPartitionWorkload", previewOfWorkload); return response; }
/** * Called by Gluon CloudLink when a list with the specified identifier is retrieved for the first time from the * client application, but does noet yet exist in Gluon CloudLink. This implementation will return all the Notes * from the database to Gluon CloudLink as a JSON Array in the correct format. * * The format that Gluon CloudLink expects, is a JSON Array where each element is a JSON Object with the following * two keys: * <ul> * <li><code>id</code>: the identifier of the Note</li> * <li><code>payload</code>: the JSON payload of the Note object, as a String</li> * </ul> * * @param listIdentifier the identifier of the list that is being retrieved from Gluon CloudLink * @return a string representation of the constructed JSON Array */ @GET @Path("/") @Produces(MediaType.APPLICATION_JSON + "; " + CHARSET) public String getList(@PathParam("listIdentifier") String listIdentifier) { LOG.log(Level.INFO, "Return list " + listIdentifier); JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(); List<Note> notes = noteService.findAll(); notes.stream().map(note -> Json.createObjectBuilder() .add("id", note.getId()) .add("payload", Json.createObjectBuilder() .add("title", note.getTitle()) .add("text", note.getText()) .add("creationDate", note.getCreationDate()) .build().toString()) .build()) .forEach(jsonArrayBuilder::add); return jsonArrayBuilder.build().toString(); }
private static Response createDataverse(TestDataverse dataverseToCreate, TestUser creator) { JsonArrayBuilder contactArrayBuilder = Json.createArrayBuilder(); contactArrayBuilder.add(Json.createObjectBuilder().add("contactEmail", creator.getEmail())); JsonArrayBuilder subjectArrayBuilder = Json.createArrayBuilder(); subjectArrayBuilder.add("Other"); JsonObject dvData = Json.createObjectBuilder() .add("alias", dataverseToCreate.alias) .add("name", dataverseToCreate.name) .add("dataverseContacts", contactArrayBuilder) .add("dataverseSubjects", subjectArrayBuilder) .build(); Response createDataverseResponse = given() .body(dvData.toString()).contentType(ContentType.JSON) .when().post("/api/dataverses/:root?key=" + creator.apiToken); return createDataverseResponse; }
@GET @ApiOperation(value = "Get languages", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of supported languages"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) public Response getLanguages() { JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); for (String lang : PropertiesLoader.SUPPORTED_LANGUAGES) { arrayBuilder.add(lang); } return Response.ok().entity(arrayBuilder.build()).build(); }
@GET @ApiOperation(value = "Get timezones", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of timezones. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) public Response getTimeZones() { JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); for (String timeZone : TimeZone.getAvailableIDs()) { arrayBuilder.add(timeZone); } return Response.ok().entity(arrayBuilder.build()).build(); }
@GET @Produces("application/json") public Response dumpStackTrace() { JsonArrayBuilder threadsArrayJson = Json.createArrayBuilder(); for (ThreadInfo info : jmxInspector.getThreadInfo()) { JsonObjectBuilder threadJson = Json.createObjectBuilder(); threadJson.add("threadName", info.getThreadName()) .add("threadId", info.getThreadId()) .add("blockedTime", info.getBlockedTime()) .add("blockedCount", info.getBlockedCount()) .add("waitedTime", info.getWaitedTime()) .add("waitedCount", info.getWaitedCount()) .add("lockName", nullSafe(info.getLockName())) .add("lockOwnerName", nullSafe(info.getLockOwnerName())) .add("inNative", info.isInNative()) .add("suspended", info.isSuspended()) .add("threadState", info.getThreadState().toString()) .add("stackTrace", buildStackTrace(info.getStackTrace())) .add("lockedMonitors", buildLockedMonitors(info.getLockedMonitors())) .add("lockedSynchronizers", buildLockedSynchronizers(info.getLockedSynchronizers())) .add("lockInfo", buildLockInfo(info.getLockInfo())); threadsArrayJson.add(threadJson); } return Response.ok(threadsArrayJson.build()).build(); }
public String toJson() { JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("id", id) .add("templateid", getTemplateId()) .add("topic", getTopic()) .add("rate", getRate()) .add("controltopic", controlTopic); JsonArrayBuilder functionsBuilder = Json.createArrayBuilder(); for (FunctionConfiguration ms : metrics) { ms.toJson(functionsBuilder); } builder.add("functions", functionsBuilder); return builder.build().toString(); }
/** * Retrieves representation of an instance of com.amazonaws.soderlun.iot.mqttloadapp.MetricsSeriesCollectionResource * @return an instance of java.lang.String */ @GET @Produces("application/json") public String getJson() { List<RunningLoadConfiguration> configs = LoadConfigurationRuntimeRegistry.getInstance().getAllRunning(); JsonArrayBuilder builder = Json.createArrayBuilder(); for (RunningLoadConfiguration rms : configs) { builder.add(rms.toJsonObject()); } StringWriter writer = new StringWriter(); try (JsonWriter jw = Json.createWriter(writer)) { jw.writeArray(builder.build()); } return writer.toString(); }
/** * Turn the list of bullets into a JSON array builder * @return json */ private JsonArrayBuilder bulletsToJSON() { final JsonArrayBuilder obj = Json.createArrayBuilder(); int ct = 0; for ( String b : bullets ) { if ( b == null ) continue; obj.add( b ); if ( ++ct == 5 ) break; } return obj; }
/** * Turn the CPSIA statements into a json array * @return json */ private JsonArrayBuilder cpsiaToJSON() { final JsonArrayBuilder obj = Json.createArrayBuilder(); int ct = 0; for ( CPSIA c : cpsiaStatements ) { if ( c == null ) continue; obj.add( c.getText()); if ( ++ct == 7 ) break; } return obj; }
@Override public JsonObjectBuilder toJSON() { JsonArrayBuilder blocks = Json.createArrayBuilder(); for (Block block : this.blocks) { blocks.add(block.toJSON()); } JsonArrayBuilder themes = Json.createArrayBuilder(); for (String theme : this.themes) { themes.add(theme); } return Json.createObjectBuilder() .add("gridWidth", gridWidth) .add("gridHeight", gridHeight) .add("themes", themes) .add("blocks", blocks); }
/** * Turn the alternate images into json * @return alt images */ private JsonArrayBuilder altImgToJSON() { final JsonArrayBuilder obj = Json.createArrayBuilder(); for ( ProductImageSlot key : alternateImages.keySet()) { obj.add( Json.createObjectBuilder() .add( "image_slot_id", key.getSlot()) .add( "image_url", alternateImages.get( key )) .build() ); } return obj; }
/** * Retrieve the JSON representation of this object * @return JSON */ @Override public JsonObject toJSON() { final JsonObjectBuilder b = Json.createObjectBuilder() .add( "price", price.asBigDecimal()); if ( !fNodes.isEmpty()) { final JsonArrayBuilder a = Json.createArrayBuilder(); for ( final FNodePriceRec rec : fNodes ) { a.add( rec.toJSON()); } b.add( "fulfillment_nodes", a ); } return b.build(); }