}
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (!(json instanceof JsonPrimitive)) {
throw new JsonParseException("The date should be a string value");
}
try {
BASE64Decoder decode = new BASE64Decoder();
return base64;
} catch (IOException ex) {
}
return null;
}
}
使用这个类将byte[]通过base64进行压缩,降低JSON的数据量4倍左右。
摘自 狐狸爱上猫----JAVA LINUX SWING EXTJS AJAX专栏