Java Code Examples for com.eclipsesource.json.JsonValue#asBoolean()
The following examples show how to use
com.eclipsesource.json.JsonValue#asBoolean() .
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: 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 2
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 3
Source File: EmailAlias.java From box-java-sdk with Apache License 2.0 | 6 votes |
@Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); try { if (memberName.equals("id")) { this.id = value.asString(); } else if (memberName.equals("is_confirmed")) { this.isConfirmed = value.asBoolean(); } else if (memberName.equals("email")) { this.email = value.asString(); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 4
Source File: WebServer.java From r2cloud with Apache License 2.0 | 5 votes |
public static boolean getBoolean(JsonValue value, String name) { JsonValue result = ((JsonObject) value).get(name); if (result == null || result.isNull()) { return false; } return result.asBoolean(); }
Example 5
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 6
Source File: JsonConfig.java From ServerSync with GNU General Public License v3.0 | 5 votes |
private static boolean getBoolean(JsonObject root, String name) throws IOException { JsonValue jsv = root.get(name); if (jsv.isNull()) { throw new IOException(String.format("No %s value present in configuration file", name)); } if (!jsv.isBoolean()) { throw new IOException(String.format("Invalid value for %s, expected boolean", name)); } return jsv.asBoolean(); }
Example 7
Source File: BoxSharedLink.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); try { if (memberName.equals("url")) { this.url = value.asString(); } else if (memberName.equals("download_url")) { this.downloadUrl = value.asString(); } else if (memberName.equals("vanity_url")) { this.vanityUrl = value.asString(); } else if (memberName.equals("is_password_enabled")) { this.isPasswordEnabled = value.asBoolean(); } else if (memberName.equals("unshared_at")) { this.unsharedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("download_count")) { this.downloadCount = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("preview_count")) { this.previewCount = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("access")) { this.access = this.parseAccessValue(value); } else if (memberName.equals("effective_access")) { this.effectiveAccess = this.parseAccessValue(value); } else if (memberName.equals("permissions")) { if (this.permissions == null) { this.setPermissions(new Permissions(value.asObject())); } else { this.permissions.update(value.asObject()); } } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 8
Source File: BoxSharedLink.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("can_download")) { this.canDownload = value.asBoolean(); } else if (memberName.equals("can_preview")) { this.canPreview = value.asBoolean(); } }
Example 9
Source File: BoxFile.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_set_share_access")) { permissions.add(Permission.CAN_SET_SHARE_ACCESS); } else if (memberName.equals("can_preview")) { permissions.add(Permission.CAN_PREVIEW); } else if (memberName.equals("can_comment")) { permissions.add(Permission.CAN_COMMENT); } } return permissions; }
Example 10
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 11
Source File: BoxTermsOfServiceUserStatus.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("tos")) { JsonObject tosJSON = value.asObject(); String termsOfServiceID = tosJSON.get("id").asString(); BoxTermsOfService termsOfService = new BoxTermsOfService(getAPI(), termsOfServiceID); this.termsOfService = termsOfService.new Info(tosJSON); } else 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("is_accepted")) { this.isAccepted = value.asBoolean(); } 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("type")) { this.termsOfServiceUserStatusType = value.asString(); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 12
Source File: BoxTask.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("item")) { JsonObject itemJSON = value.asObject(); String itemID = itemJSON.get("id").asString(); BoxFile file = new BoxFile(getAPI(), itemID); this.item = file.new Info(itemJSON); } else if (memberName.equals("due_at")) { this.dueAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("action")) { this.action = value.asString(); } else if (memberName.equals("completion_rule")) { this.completionRule = value.asString(); } else if (memberName.equals("message")) { this.message = value.asString(); } else if (memberName.equals("task_assignment_collection")) { this.taskAssignments = this.parseTaskAssignmentCollection(value.asObject()); } else if (memberName.equals("is_completed")) { this.completed = value.asBoolean(); } else if (memberName.equals("created_by")) { JsonObject userJSON = value.asObject(); String userID = userJSON.get("id").asString(); BoxUser user = new BoxUser(getAPI(), userID); this.createdBy = user.new Info(userJSON); } else if (memberName.equals("created_at")) { this.createdAt = BoxDateFormat.parse(value.asString()); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 13
Source File: BlockJson.java From Cubes with MIT License | 4 votes |
@Override public Boolean parse(JsonValue prop) { return prop.asBoolean(); }
Example 14
Source File: BoxLegalHoldPolicy.java From box-java-sdk with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); String memberName = member.getName(); JsonValue value = member.getValue(); try { if (memberName.equals("policy_name")) { this.policyName = value.asString(); } else if (memberName.equals("description")) { this.description = value.asString(); } else if (memberName.equals("status")) { this.status = value.asString(); } else if (memberName.equals("release_notes")) { this.releaseNotes = value.asString(); } else if (memberName.equals("assignment_counts")) { JsonObject countsJSON = value.asObject(); this.assignmentCountUser = countsJSON.get("user").asInt(); this.assignmentCountFolder = countsJSON.get("folder").asInt(); this.assignmentCountFile = countsJSON.get("file").asInt(); this.assignmentCountFileVersion = countsJSON.get("file_version").asInt(); } else 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("deleted_at")) { this.deletedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("filter_started_at")) { this.filterStartedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("filter_ended_at")) { this.filterEndedAt = BoxDateFormat.parse(value.asString()); } else if (memberName.equals("is_ongoing")) { this.isOngoing = value.asBoolean(); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 15
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 16
Source File: BoxUser.java From box-java-sdk with Apache License 2.0 | 4 votes |
@Override protected void parseJSONMember(JsonObject.Member member) { super.parseJSONMember(member); JsonValue value = member.getValue(); String memberName = member.getName(); try { if (memberName.equals("login")) { this.login = value.asString(); } else if (memberName.equals("role")) { this.role = Role.fromJSONValue(value.asString()); } else if (memberName.equals("language")) { this.language = value.asString(); } else if (memberName.equals("timezone")) { this.timezone = value.asString(); } else if (memberName.equals("space_amount")) { this.spaceAmount = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("space_used")) { this.spaceUsed = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("max_upload_size")) { this.maxUploadSize = Double.valueOf(value.toString()).longValue(); } else if (memberName.equals("status")) { this.status = Status.fromJSONValue(value.asString()); } else if (memberName.equals("job_title")) { this.jobTitle = value.asString(); } else if (memberName.equals("phone")) { this.phone = value.asString(); } else if (memberName.equals("address")) { this.address = value.asString(); } else if (memberName.equals("avatar_url")) { this.avatarURL = value.asString(); } else if (memberName.equals("can_see_managed_users")) { this.canSeeManagedUsers = value.asBoolean(); } else if (memberName.equals("is_sync_enabled")) { this.isSyncEnabled = value.asBoolean(); } else if (memberName.equals("is_external_collab_restricted")) { this.isExternalCollabRestricted = value.asBoolean(); } else if (memberName.equals("is_exempt_from_device_limits")) { this.isExemptFromDeviceLimits = value.asBoolean(); } else if (memberName.equals("is_exempt_from_login_verification")) { this.isExemptFromLoginVerification = value.asBoolean(); } else if (memberName.equals("is_password_reset_required")) { this.isPasswordResetRequired = value.asBoolean(); } else if (memberName.equals("is_platform_access_only")) { this.isPlatformAccessOnly = value.asBoolean(); } else if (memberName.equals("external_app_user_id")) { this.externalAppUserId = value.asString(); } else if (memberName.equals("enterprise")) { JsonObject jsonObject = value.asObject(); if (this.enterprise == null) { this.enterprise = new BoxEnterprise(jsonObject); } else { this.enterprise.update(jsonObject); } } else if (memberName.equals("my_tags")) { this.myTags = this.parseMyTags(value.asArray()); } else if (memberName.equals("hostname")) { this.hostname = value.asString(); } else if (memberName.equals("tracking_codes")) { this.trackingCodes = this.parseTrackingCodes(value.asArray()); } } catch (Exception e) { throw new BoxDeserializationException(memberName, value.toString(), e); } }
Example 17
Source File: BooleanSetting.java From Cubes with MIT License | 4 votes |
@Override public void readJson(JsonValue json) { this.b = json.asBoolean(); onChange(); }
Example 18
Source File: JsonHelper.java From typescript.java with MIT License | 4 votes |
public static Boolean getBoolean(JsonObject obj, String name) { JsonValue value = obj.get(name); return value != null ? value.asBoolean() : null; }
Example 19
Source File: FractionListParser.java From thorntail with Apache License 2.0 | 4 votes |
private boolean toBoolean(JsonValue jsonValue) { return jsonValue.isNull() ? false : jsonValue.asBoolean(); }
Example 20
Source File: FractionList.java From wildfly-swarm with Apache License 2.0 | 4 votes |
private boolean toBoolean(JsonValue jsonValue) { return jsonValue.isNull() ? false : jsonValue.asBoolean(); }