FastJsonSerialization implements Serialization { @Override public byte[] serialize(Object data) throws IOException { SerializeWriter out = new SerializeWriter(); JSONSerializer serializer = new JSONSerializer(out); serializer.config(SerializerFeature.WriteEnumUsingToString, true); serializer.config(SerializerFeature.WriteClassName, true); serializer.write(data); return out.toBytes("UTF-8"); }  @Override byte[] serialize(Object data); @Override T deserialize(byte[] data, Class<T> clz); @Override byte[] serializeMulti(Object[] data); @Override Object[] deserializeMulti(byte[] data, Class<?>[] classes); @Override int getSerializationNumber();  }
@Test public void serialize() throws Exception { UserAttentions userAttentions = new UserAttentions(); userAttentions.setUid(12312); byte[] bytes = serialization.serialize(userAttentions); UserAttentions u2 = serialization.deserialize(bytes, UserAttentions.class); Assert.assertEquals(u2.getUid(), userAttentions.getUid()); }