julman99 / gson-fire

A java library that adds some very useful features to Gson, like Date serializing to unix timestamp or RFC3339, method (getters) serialization, pre/post processors and many others. Check out the documentation to learn how to use it!
http://gsonfire.io
Other
229 stars 37 forks source link

Adds Wrap feature to wrap/unwrap classes #27

Closed andressanchez closed 8 years ago

andressanchez commented 8 years ago

This pull request implements a new feature to wrap/unwrap classes.

public class A {
  @Expose
   public String str1;
}
GsonFireBuilder gsonFireBuilder = new GsonFireBuilder()
    .wrap(A.class, new Mapper<A, String>() {
        @Override
        public String map(A from) {
            return "aWrap";
        }
    });
GsonFireBuilder gsonFireBuilder = new GsonFireBuilder()
    .wrap(A.class, "aWrap");

It will be serialized to / deserialized from

{
  aWrap: {
    str1: "v1"
  }
}

instead of

{
  str1: "v1"
}
julman99 commented 8 years ago

Please add changes also to the README file