Java Code Examples for com.eclipsesource.json.JsonObject#Member
The following examples show how to use
com.eclipsesource.json.JsonObject#Member .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Representation.java From box-java-sdk with Apache License 2.0 | 6 votes |
/** * Construct a representation from JsonObject. * @param representationJson representaion entry */ public Representation(JsonObject representationJson) { for (JsonObject.Member member : representationJson) { if (member.getName().equals("representation")) { this.representation = member.getValue().asString(); } else if (member.getName().equals("properties")) { this.properties = member.getValue().asObject(); } else if (member.getName().equals("metadata")) { this.metadata = member.getValue().asObject(); } else if (member.getName().equals("info")) { this.info = new Info(member.getValue().asObject()); } else if (member.getName().equals("content")) { this.content = new Content(member.getValue().asObject()); } else if (member.getName().equals("status")) { this.status = new Status(member.getValue().asObject()); } } }
Example 2
Source File: BoxFileUploadSessionPartList.java From box-java-sdk with Apache License 2.0 | 6 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { String memberName = member.getName(); JsonValue value = member.getValue(); if (memberName.equals("entries")) { JsonArray array = (JsonArray) value; if (array.size() > 0) { this.entries = this.getParts(array); } } else if (memberName.equals("offset")) { this.offset = Double.valueOf(value.toString()).intValue(); } else if (memberName.equals("limit")) { this.limit = Double.valueOf(value.toString()).intValue(); } else if (memberName.equals("total_count")) { this.totalCount = Double.valueOf(value.toString()).intValue(); } }
Example 3
Source File: Parsers.java From box-java-sdk with Apache License 2.0 | 6 votes |
/** * Creates a map of metadata from json. * @param jsonObject metadata json object for metadata field in get /files?fileds=,etadata.scope.template response * @return Map of String as key a value another Map with a String key and Metadata value */ public static Map<String, Map<String, Metadata>> parseAndPopulateMetadataMap(JsonObject jsonObject) { Map<String, Map<String, Metadata>> metadataMap = new HashMap<String, Map<String, Metadata>>(); //Parse all templates for (JsonObject.Member templateMember : jsonObject) { if (templateMember.getValue().isNull()) { continue; } else { String templateName = templateMember.getName(); Map<String, Metadata> scopeMap = metadataMap.get(templateName); //If templateName doesn't yet exist then create an entry with empty scope map if (scopeMap == null) { scopeMap = new HashMap<String, Metadata>(); metadataMap.put(templateName, scopeMap); } //Parse all scopes in a template for (JsonObject.Member scopeMember : templateMember.getValue().asObject()) { String scope = scopeMember.getName(); Metadata metadataObject = new Metadata(scopeMember.getValue().asObject()); scopeMap.put(scope, metadataObject); } } } return metadataMap; }
Example 4
Source File: MetadataTemplate.java From box-java-sdk with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("templateKey")) { this.templateKey = value.asString(); } else if (memberName.equals("scope")) { this.scope = value.asString(); } else if (memberName.equals("displayName")) { this.displayName = value.asString(); } else if (memberName.equals("hidden")) { this.isHidden = value.asBoolean(); } else if (memberName.equals("fields")) { this.fields = new ArrayList<Field>(); for (JsonValue field: value.asArray()) { this.fields.add(new Field(field.asObject())); } } else if (memberName.equals("id")) { this.id = value.asString(); } }
Example 5
Source File: MetadataTemplate.java From box-java-sdk with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("type")) { this.type = value.asString(); } else if (memberName.equals("key")) { this.key = value.asString(); } else if (memberName.equals("displayName")) { this.displayName = value.asString(); } else if (memberName.equals("hidden")) { this.isHidden = value.asBoolean(); } else if (memberName.equals("description")) { this.description = value.asString(); } else if (memberName.equals("options")) { this.options = new ArrayList<Option>(); for (JsonValue option : value.asArray()) { this.options.add(new Option(option.asObject())); } } else if (memberName.equals("id")) { this.id = value.asString(); } }
Example 6
Source File: BoxFileUploadSession.java From box-java-sdk with Apache License 2.0 | 6 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("list_parts")) { this.listPartsEndpoint = new URL(value.asString()); } else if (memberName.equals("commit")) { this.commitEndpoint = new URL(value.asString()); } else if (memberName.equals("upload_part")) { this.uploadPartEndpoint = new URL(value.asString()); } else if (memberName.equals("status")) { this.statusEndpoint = new URL(value.asString()); } else if (memberName.equals("abort")) { this.abortEndpoint = new URL(value.asString()); } } catch (MalformedURLException mue) { assert false : "A ParseException indicates a bug in the SDK."; } }
Example 7
Source File: BoxStoragePolicy.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("name")) { this.storagePolicyName = value.asString(); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 8
Source File: BoxCollaborationWhitelist.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("domain")) { this.domain = value.asString(); } else if (memberName.equals("type")) { this.type = value.asString(); } else if (memberName.equals("direction")) { this.direction = WhitelistDirection.fromDirection(value.asString()); } else if (memberName.equals("enterprise")) { JsonObject jsonObject = value.asObject(); this.enterprise = new BoxEnterprise(jsonObject); } else if (memberName.equals("created_at")) { this.createdAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("modified_at")) { this.modifiedAt = BoxDateFormat.parse(value.asString()); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 9
Source File: BoxLegalHoldAssignment.java From box-java-sdk with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("legal_hold_policy")) { JsonObject policyJSON = value.asObject(); if (this.legalHold == null) { String policyID = policyJSON.get("id").asString(); BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(getAPI(), policyID); this.legalHold = policy.new Info(policyJSON); } else { this.legalHold.update(policyJSON); } } else if (memberName.equals("assigned_to")) { JsonObject assignmentJSON = value.asObject(); this.assignedToType = assignmentJSON.get("type").asString(); this.assignedToID = assignmentJSON.get("id").asString(); } else if (memberName.equals("assigned_by")) { JsonObject userJSON = value.asObject(); if (this.assignedBy == null) { String userID = userJSON.get("id").asString(); BoxUser user = new BoxUser(getAPI(), userID); this.assignedBy = user.new Info(userJSON); } else { this.assignedBy.update(userJSON); } } else if (memberName.equals("assigned_at")) { this.assignedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("deleted_at")) { this.deletedAt = BoxDateFormat.parse(value.asString()); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 10
Source File: Representation.java From box-java-sdk with Apache License 2.0 | 5 votes |
/** * Construct a representation's content. * @param members json object */ public Content(JsonObject members) { for (JsonObject.Member member : members) { if (member.getName().equals("url_template")) { this.urlTemplate = member.getValue().asString(); } } }
Example 11
Source File: MetadataTemplate.java From box-java-sdk with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("id")) { this.id = value.asString(); } else if (memberName.equals("key")) { this.key = value.asString(); } }
Example 12
Source File: BoxEvent.java From box-java-sdk with Apache License 2.0 | 5 votes |
BoxEvent(BoxAPIConnection api, JsonObject jsonObject) { super(api, jsonObject.get("event_id").asString()); for (JsonObject.Member member : jsonObject) { if (member.getValue().isNull()) { continue; } this.parseJsonMember(member); } }
Example 13
Source File: BoxLock.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("type")) { this.type = value.asString(); } else if (memberName.equals("expires_at")) { this.expiresAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("is_download_prevented")) { this.isDownloadPrevented = value.asBoolean(); } else if (memberName.equals("created_by")) { JsonObject userJSON = value.asObject(); if (this.createdBy == null) { String userID = userJSON.get("id").asString(); BoxUser user = new BoxUser(this.api, userID); this.createdBy = user.new Info(userJSON); } else { this.createdBy.update(userJSON); } } else if (memberName.equals("created_at")) { this.createdAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("id")) { this.id = value.toString(); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 14
Source File: BoxFileUploadSessionPart.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { String memberName = member.getName(); JsonValue value = member.getValue(); if (memberName.equals("part_id")) { this.partId = value.asString(); } else if (memberName.equals("offset")) { this.offset = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("size")) { this.size = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("sha1")) { this.sha1 = value.asString(); } }
Example 15
Source File: BoxCollaborationWhitelistExemptTarget.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("user")) { JsonObject userJSON = value.asObject(); String userID = userJSON.get("id").asString(); BoxUser user = new BoxUser(getAPI(), userID); this.user = user.new Info(userJSON); } else if (memberName.equals("type")) { this.type = value.asString(); } else if (memberName.equals("enterprise")) { JsonObject jsonObject = value.asObject(); this.enterprise = new BoxEnterprise(jsonObject); } else if (memberName.equals("created_at")) { this.createdAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("modified_at")) { this.modifiedAt = BoxDateFormat.parse(value.asString()); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 16
Source File: BoxWatermark.java From box-java-sdk with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); if (memberName.equals(WATERMARK_JSON_KEY)) { try { this.createdAt = BoxDateFormat.parse(value.asObject().get(CREATED_AT_JSON_KEY).asString()); this.modifiedAt = BoxDateFormat.parse(value.asObject().get(MODIFIED_AT_JSON_KEY).asString()); } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } } }
Example 17
Source File: BoxFolder.java From box-java-sdk with Apache License 2.0 | 5 votes |
private EnumSet<Permission> parsePermissions(JsonObject jsonObject) { EnumSet<Permission> permissions = EnumSet.noneOf(Permission.class); for (JsonObject.Member member : jsonObject) { JsonValue value = member.getValue(); if (value.isNull() || !value.asBoolean()) { continue; } String memberName = member.getName(); if (memberName.equals("can_download")) { permissions.add(Permission.CAN_DOWNLOAD); } else if (memberName.equals("can_upload")) { permissions.add(Permission.CAN_UPLOAD); } else if (memberName.equals("can_rename")) { permissions.add(Permission.CAN_RENAME); } else if (memberName.equals("can_delete")) { permissions.add(Permission.CAN_DELETE); } else if (memberName.equals("can_share")) { permissions.add(Permission.CAN_SHARE); } else if (memberName.equals("can_invite_collaborator")) { permissions.add(Permission.CAN_INVITE_COLLABORATOR); } else if (memberName.equals("can_set_share_access")) { permissions.add(Permission.CAN_SET_SHARE_ACCESS); } } return permissions; }
Example 18
Source File: BoxCollaboration.java From box-java-sdk with Apache License 2.0 | 4 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("created_by")) { JsonObject userJSON = value.asObject(); if (this.createdBy == null) { String userID = userJSON.get("id").asString(); BoxUser user = new BoxUser(getAPI(), userID); this.createdBy = user.new Info(userJSON); } else { this.createdBy.update(userJSON); } } else if (memberName.equals("created_at")) { this.createdAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("modified_at")) { this.modifiedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("expires_at")) { this.expiresAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("status")) { String statusString = value.asString().toUpperCase(); this.status = Status.valueOf(statusString); } else if (memberName.equals("accessible_by")) { JsonObject accessibleByJSON = value.asObject(); if (this.accessibleBy == null) { this.accessibleBy = this.parseAccessibleBy(accessibleByJSON); } else { this.updateAccessibleBy(accessibleByJSON); } } else if (memberName.equals("role")) { this.role = Role.fromJSONString(value.asString()); } else if (memberName.equals("acknowledged_at")) { this.acknowledgedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("can_view_path")) { this.canViewPath = value.asBoolean(); } else if (memberName.equals("invite_email")) { this.inviteEmail = value.asString(); } else if (memberName.equals("item")) { JsonObject folderJSON = value.asObject(); if (this.item == null) { String folderID = folderJSON.get("id").asString(); BoxFolder folder = new BoxFolder(getAPI(), folderID); this.item = folder.new Info(folderJSON); } else { this.item.update(folderJSON); } } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 19
Source File: SkypeImpl.java From Skype4J with Apache License 2.0 | 4 votes |
public void registerWebSocket() throws ConnectionException, InterruptedException, URISyntaxException, KeyManagementException, NoSuchAlgorithmException, UnsupportedEncodingException { boolean needsToRegister = false; if (trouterData == null) { trouterData = Endpoints.TROUTER_URL .open(this) .as(JsonObject.class) .expect(200, "While fetching trouter data") .post(); needsToRegister = true; } else { Endpoints.RECONNECT_WEBSOCKET .open(this, trouterData.get("connId")) .expect(200, "Requesting websocket reconnect") .post(); } JsonObject policyResponse = Endpoints.POLICIES_URL .open(this) .as(JsonObject.class) .expect(200, "While fetching policy data") .post(new JsonObject().add("sr", trouterData.get("connId"))); Map<String, String> data = new HashMap<>(); for (JsonObject.Member value : policyResponse) { data.put(value.getName(), Utils.coerceToString(value.getValue())); } data.put("r", Utils.coerceToString(trouterData.get("instance"))); data.put("p", String.valueOf(trouterData.get("instancePort").asInt())); data.put("ccid", Utils.coerceToString(trouterData.get("ccid"))); data.put("v", "v2"); //TODO: MAGIC VALUE data.put("dom", "web.skype.com"); //TODO: MAGIC VALUE data.put("auth", "true"); //TODO: MAGIC VALUE data.put("tc", new JsonObject() .add("cv", "2015.11.05") .add("hr", "") .add("v", "1.34.99") .toString()); //TODO: MAGIC VALUE data.put("timeout", "55"); data.put("t", String.valueOf(System.currentTimeMillis())); StringBuilder args = new StringBuilder(); for (Map.Entry<String, String> entry : data.entrySet()) { args .append(URLEncoder.encode(entry.getKey(), "UTF-8")) .append("=") .append(URLEncoder.encode(entry.getValue(), "UTF-8")) .append("&"); } String socketio = Utils.coerceToString(trouterData.get("socketio")); if (socketio.endsWith("/")) { socketio = socketio.substring(0, socketio.length() - 1); } String socketURL = socketio + "/socket.io/" + socketId + "/?" + args.toString(); String websocketData = Endpoints .custom(socketURL, this) .as(String.class) .expect(200, "While fetching websocket details") .get(); if (needsToRegister) { Endpoints.REGISTRATIONS .open(this) .expect(202, "While registering websocket") .post(new JsonObject() .add("clientDescription", new JsonObject() .add("aesKey", "") .add("languageId", "en-US") .add("platform", "Chrome") .add("platformUIVersion", Skype.VERSION) .add("templateKey", "SkypeWeb_1.1")) .add("registrationId", UUID.randomUUID().toString()) .add("nodeId", "") .add("transports", new JsonObject().add("TROUTER", new JsonArray().add(new JsonObject() .add("context", "") .add("ttl", 3600) .add("path", trouterData.get("surl")))))); } this.wss = new SkypeWebSocket(this, new URI(String.format("%s/socket.io/" + socketId + "/websocket/%s?%s", "wss://" + socketio.replaceAll("https?://", "").replace(":443", ""), websocketData.split(":")[0], args.toString()))); this.wss.connectBlocking(); socketId++; }
Example 20
Source File: BoxJsonObject.java From box-android-sdk with Apache License 2.0 | 2 votes |
/** * Invoked with a JSON member whenever this object is updated or created from a JSON object. * * <p> * Subclasses should override this method in order to parse any JSON members it knows about. This method is a no-op by default. * </p> * * @param member * the JSON member to be parsed. */ @Deprecated protected void parseJSONMember(JsonObject.Member member) { }