Code example for JsonSerializationContext

Methods: serialize

	public JsonElement serialize(IdentityProxy src, Type srcType, JsonSerializationContext context) {
		if(SerializationContext.current().getUuidTranslation()) { 
			assert(src != null);
			if(src.getValue() == null)
				return context.serialize(null);
			IdentityDao identityDao = new IdentityDaoImpl();
			if(src.getTableName() != null) {
				String uuid = identityDao.getIdentityUuid(src.getTableName(), String.valueOf(src.getValue()));
				if(uuid == null)
					return context.serialize(null);
				// Exceptions set the _idFieldName in the IdentityProxy structure. So if this field is not 
				// null, prepare a structure of uuid and idFieldName and return the json representation of that. 
				String idName = src.getidFieldName();
				if (idName != null) {
					// Prepare a structure. 
					JsonObject jsonObj = new JsonObject();
					jsonObj.add("uuid", new JsonPrimitive(uuid));
Connect your IDE to all the code out there  Get Codota for Java