I\'m trying to use Realm + GSON. If they would work together well, it would be a match made in heaven.
However, when I extend my model objects with \"extends RealmOb
U can do it like this:
Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getDeclaringClass().equals(RealmObject.class);
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
return false;
}
})
.create();
String json = "{ name : 'John', email : 'john@corporation.com' }";
User user = gson.fromJson(json, User.class);
http://realm.io/docs/java/0.77.0/#gson