use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxGroup method getCollaborations.
/**
* Gets information about all of the collaborations for this group.
*
* @return a collection of information about the collaborations for this group.
*/
public Collection<BoxCollaboration.Info> getCollaborations() {
BoxAPIConnection api = this.getAPI();
URL url = COLLABORATIONS_URL_TEMPLATE.build(api.getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = Json.parse(response.getJSON()).asObject();
int entriesCount = responseJSON.get("total_count").asInt();
Collection<BoxCollaboration.Info> collaborations = new ArrayList<>(entriesCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue entry : entries) {
JsonObject entryObject = entry.asObject();
BoxCollaboration collaboration = new BoxCollaboration(api, entryObject.get("id").asString());
BoxCollaboration.Info info = collaboration.new Info(entryObject);
collaborations.add(info);
}
return collaborations;
}
use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxUser method getEmailAliases.
/**
* Gets a collection of all the email aliases for this user.
*
* <p>Note that the user's primary login email is not included in the collection of email aliases.</p>
*
* @return a collection of all the email aliases for this user.
*/
public Collection<EmailAlias> getEmailAliases() {
URL url = EMAIL_ALIASES_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = Json.parse(response.getJSON()).asObject();
int totalCount = responseJSON.get("total_count").asInt();
Collection<EmailAlias> emailAliases = new ArrayList<>(totalCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue value : entries) {
JsonObject emailAliasJSON = value.asObject();
emailAliases.add(new EmailAlias(emailAliasJSON));
}
return emailAliases;
}
use of com.eclipsesource.json.JsonValue in project hazelcast by hazelcast.
the class JsonUtil method getObject.
/**
* Returns a field in a Json object as an object.
* Throws IllegalArgumentException if the field value is null.
*
* @param object the Json object
* @param field the field in the Json object to return
* @return the Json field value as a Json object
*/
public static JsonObject getObject(JsonObject object, String field) {
final JsonValue value = object.get(field);
throwExceptionIfNull(value, field);
return value.asObject();
}
use of com.eclipsesource.json.JsonValue in project hazelcast by hazelcast.
the class JsonUtil method getString.
/**
* Returns a field in a Json object as a string.
* Throws IllegalArgumentException if the field value is null.
*
* @param object the Json Object
* @param field the field in the Json object to return
* @return the Json field value as a string
*/
public static String getString(JsonObject object, String field) {
final JsonValue value = object.get(field);
throwExceptionIfNull(value, field);
return value.asString();
}
use of com.eclipsesource.json.JsonValue in project hazelcast by hazelcast.
the class LocalOperationStatsImpl method fromJson.
@Override
public void fromJson(JsonObject json) {
maxVisibleSlowOperationCount = getLong(json, "maxVisibleSlowOperationCount", Long.MAX_VALUE);
for (JsonValue jsonValue : getArray(json, "slowOperations")) {
SlowOperationDTO slowOperationDTO = new SlowOperationDTO();
slowOperationDTO.fromJson(jsonValue.asObject());
slowOperations.add(slowOperationDTO);
}
creationTime = getLong(json, "creationTime", -1L);
}
Aggregations