use of com.google.gson.JsonPrimitive in project wcomponents by BorderTech.
the class TreeItemUtil method processJsonToTree.
/**
* Iterate over the JSON objects to create the tree structure.
*
* @param parentNode the parent node
* @param json the current JSON object
*/
private static void processJsonToTree(final TreeItemIdNode parentNode, final JsonObject json) {
String id = json.getAsJsonPrimitive("id").getAsString();
JsonPrimitive expandableJson = json.getAsJsonPrimitive("expandable");
TreeItemIdNode node = new TreeItemIdNode(id);
if (expandableJson != null && expandableJson.getAsBoolean()) {
node.setHasChildren(true);
}
parentNode.addChild(node);
JsonArray children = json.getAsJsonArray("items");
if (children != null) {
for (int i = 0; i < children.size(); i++) {
JsonObject child = children.get(i).getAsJsonObject();
processJsonToTree(node, child);
}
}
}
use of com.google.gson.JsonPrimitive in project blogwt by billy1380.
the class Message method toJson.
@Override
public JsonObject toJson() {
JsonObject object = super.toJson();
JsonElement jsonTitle = title == null ? JsonNull.INSTANCE : new JsonPrimitive(title);
object.add("title", jsonTitle);
JsonElement jsonBody = body == null ? JsonNull.INSTANCE : new JsonPrimitive(body);
object.add("body", jsonBody);
JsonElement jsonClick_action = click_action == null ? JsonNull.INSTANCE : new JsonPrimitive(click_action);
object.add("click_action", jsonClick_action);
return object;
}
use of com.google.gson.JsonPrimitive in project blogwt by billy1380.
the class Payload method toJson.
@Override
public JsonObject toJson() {
JsonObject object = super.toJson();
JsonElement jsonTo = to == null ? JsonNull.INSTANCE : new JsonPrimitive(to);
object.add("to", jsonTo);
JsonElement jsonRegistration_ids = JsonNull.INSTANCE;
if (registration_ids != null) {
jsonRegistration_ids = new JsonArray();
for (int i = 0; i < registration_ids.size(); i++) {
JsonElement jsonRegistration_idsItem = registration_ids.get(i) == null ? JsonNull.INSTANCE : new JsonPrimitive(registration_ids.get(i));
((JsonArray) jsonRegistration_ids).add(jsonRegistration_idsItem);
}
}
object.add("registration_ids", jsonRegistration_ids);
JsonElement jsonCondition = condition == null ? JsonNull.INSTANCE : new JsonPrimitive(condition);
object.add("condition", jsonCondition);
JsonElement jsonCollapse_key = collapse_key == null ? JsonNull.INSTANCE : new JsonPrimitive(collapse_key);
object.add("collapse_key", jsonCollapse_key);
JsonElement jsonPriority = priority == null ? JsonNull.INSTANCE : new JsonPrimitive(priority.toString());
object.add("priority", jsonPriority);
JsonElement jsonContent_available = content_available == null ? JsonNull.INSTANCE : new JsonPrimitive(content_available);
object.add("content_available", jsonContent_available);
JsonElement jsonMutable_content = mutable_content == null ? JsonNull.INSTANCE : new JsonPrimitive(mutable_content);
object.add("mutable_content", jsonMutable_content);
JsonElement jsonTime_to_live = time_to_live == null ? JsonNull.INSTANCE : new JsonPrimitive(time_to_live);
object.add("time_to_live", jsonTime_to_live);
JsonElement jsonRestricted_package_name = restricted_package_name == null ? JsonNull.INSTANCE : new JsonPrimitive(restricted_package_name);
object.add("restricted_package_name", jsonRestricted_package_name);
JsonElement jsonDry_run = dry_run == null ? JsonNull.INSTANCE : new JsonPrimitive(dry_run);
object.add("dry_run", jsonDry_run);
JsonElement jsonData = data == null ? JsonNull.INSTANCE : data.toJson();
object.add("data", jsonData);
JsonElement jsonNotification = notification == null ? JsonNull.INSTANCE : notification.toJson();
object.add("notification", jsonNotification);
return object;
}
use of com.google.gson.JsonPrimitive in project blogwt by billy1380.
the class WebMessage method toJson.
@Override
public JsonObject toJson() {
JsonObject object = super.toJson();
JsonElement jsonIcon = icon == null ? JsonNull.INSTANCE : new JsonPrimitive(icon);
object.add("icon", jsonIcon);
return object;
}
use of com.google.gson.JsonPrimitive in project blogwt by billy1380.
the class Response method toJson.
@Override
public JsonObject toJson() {
JsonObject object = super.toJson();
JsonElement jsonStatus = status == null ? JsonNull.INSTANCE : new JsonPrimitive(status.toString());
object.add("status", jsonStatus);
JsonElement jsonError = error == null ? JsonNull.INSTANCE : error.toJson();
object.add("error", jsonError);
JsonElement jsonSession = session == null ? JsonNull.INSTANCE : session.toJson();
object.add("session", jsonSession);
return object;
}
Aggregations