List of usage examples for com.google.gson JsonSerializationContext serialize
public JsonElement serialize(Object src);
From source file:com.codereligion.bugsnag.logback.resource.TabVOSerializer.java
License:Apache License
@Override public JsonElement serialize(final TabVO src, final Type typeOfSrc, final JsonSerializationContext context) { final JsonElement jsonElement = context.serialize(src.getValuesByKey()); filterJsonElement(jsonElement);/*from w w w .ja v a2 s. co m*/ return jsonElement; }
From source file:com.cognifide.aet.vs.metadata.CollectionSerializer.java
License:Apache License
@Override public JsonElement serialize(Collection<?> src, Type typeOfSrc, JsonSerializationContext context) { if (src == null || src.isEmpty()) { return null; }//from w w w. ja va 2 s . c o m JsonArray array = new JsonArray(); for (Object child : src) { JsonElement element = context.serialize(child); array.add(element); } return array; }
From source file:com.cognifide.aet.vs.metadata.MapSerializer.java
License:Apache License
@Override public JsonElement serialize(Map<?, ?> src, Type typeOfSrc, JsonSerializationContext context) { if (src == null || src.isEmpty()) { return null; }// ww w . ja v a 2 s . co m JsonObject map = new JsonObject(); for (Map.Entry<?, ?> entry : src.entrySet()) { final Object entryKey = entry.getKey(); final String key = entryKey != null ? entryKey.toString() : ""; map.add(key, context.serialize(entry.getValue())); } return map; }
From source file:com.continuuity.loom.codec.json.current.AdministrationCodec.java
License:Apache License
@Override public JsonElement serialize(Administration administration, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("leaseduration", context.serialize(administration.getLeaseDuration())); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.ClusterDefaultsCodec.java
License:Apache License
@Override public JsonElement serialize(ClusterDefaults clusterDefaults, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("services", context.serialize(clusterDefaults.getServices())); jsonObj.add("provider", context.serialize(clusterDefaults.getProvider())); jsonObj.add("hardwaretype", context.serialize(clusterDefaults.getHardwaretype())); jsonObj.add("imagetype", context.serialize(clusterDefaults.getImagetype())); jsonObj.add("dnsSuffix", context.serialize(clusterDefaults.getDnsSuffix())); jsonObj.add("config", context.serialize(clusterDefaults.getConfig())); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.ClusterTemplateCodec.java
License:Apache License
@Override public JsonElement serialize(ClusterTemplate clusterTemplate, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", context.serialize(clusterTemplate.getName())); jsonObj.add("description", context.serialize(clusterTemplate.getDescription())); jsonObj.add("defaults", context.serialize(clusterTemplate.getClusterDefaults())); jsonObj.add("compatibility", context.serialize(clusterTemplate.getCompatibilities())); jsonObj.add("constraints", context.serialize(clusterTemplate.getConstraints(), Constraints.class)); jsonObj.add("administration", context.serialize(clusterTemplate.getAdministration(), Administration.class)); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.CompatibilitiesCodec.java
License:Apache License
@Override public JsonElement serialize(Compatibilities compatibilities, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("hardwaretypes", context.serialize(compatibilities.getHardwaretypes())); jsonObj.add("imagetypes", context.serialize(compatibilities.getHardwaretypes())); jsonObj.add("services", context.serialize(compatibilities.getHardwaretypes())); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.FieldSchemaCodec.java
License:Apache License
@Override public JsonElement serialize(FieldSchema fieldSchema, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("label", context.serialize(fieldSchema.getLabel())); jsonObj.add("type", context.serialize(fieldSchema.getType())); jsonObj.add("tip", context.serialize(fieldSchema.getTip())); jsonObj.add("default", context.serialize(fieldSchema.getDefaultValue())); jsonObj.add("override", context.serialize(fieldSchema.getOverride())); jsonObj.add("options", context.serialize(fieldSchema.getOptions())); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.HardwareTypeCodec.java
License:Apache License
@Override public JsonElement serialize(HardwareType hardwareType, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", context.serialize(hardwareType.getName())); jsonObj.add("description", context.serialize(hardwareType.getDescription())); jsonObj.add("providermap", context.serialize(hardwareType.getProviderMap())); return jsonObj; }
From source file:com.continuuity.loom.codec.json.current.ImageTypeCodec.java
License:Apache License
@Override public JsonElement serialize(ImageType imageType, Type type, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", context.serialize(imageType.getName())); jsonObj.add("description", context.serialize(imageType.getDescription())); jsonObj.add("providermap", context.serialize(imageType.getProviderMap())); return jsonObj; }