Created
June 14, 2015 03:39
-
-
Save bearprada/0cbcdf39c70f63eaca3f to your computer and use it in GitHub Desktop.
Revisions
-
bearprada created this gist
Jun 14, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ /** * Example : * input : {server: { result : { data: { a:1, b:2 }} }} **/ public class MyDeserializer implements JsonDeserializer<MyClass> { public MyClass deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonElement j = json.getAsJsonObject().get("server").getAsJsonObject().get("result").getAsJsonObject().get("data"); MyClass clz = new MyClass(); clz.data = context.deserialize(j, MyData.class); return clz; } } public class MyClass { public MyData data; } public class MyData { @Serialize("a") public int a; @Serialize("b") public int b; }