-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrofit + gson + stackoverflow #121
Comments
This appears to be a GSON issue, not a DBFlow issue. |
Thanks for your quick answer. But you know any workaround to fix this? |
looks good to me. I would debug GSON, and there is not much more I can do to help. Not that I don't want to, just I am not familiar with the library and not sure this error is a DBFlow issue. |
I solved this by using Gson's @expose annotation. Pass a custom Gson to Retrofit: Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.create();
RestAdapter restAdapter = new RestAdapter.Builder()
.setConverter(new GsonConverter(gson))
.build(); Then add the @expose annotation to all your fields (that you want to deserialize) in your Model class. Not sure why it works but it did. |
Thanks @intrications, it worked!! |
@intrications Can you give an example please? It doesn't work for me :(
Is something wrong? :( |
What is ContainerAdapter? I didn't use that.
|
@intrications It's used to save model to database by calling method
And thanks for your solution! Finally, It's work for me ^^
|
@nambv @intrications |
@agrosner Thank you very much for your explaination ^^! |
Instead of force exposing all fields, you should get the same result just by letting Gson know that it should not try to serialize/deserialize the contents of the Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getDeclaredClass().equals(ModelAdapter.class);
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
return false;
}
})
.create(); |
@rjam Many MANY THANKS! |
@rjam Thanks for that. I wasn't sure exactly what it was in |
thanks guy`s....it was helpful. |
This is also going to be an issue for anyone using Jackson + Retrofit + DBFlow. The solution is for any class that make sure you do something along the lines of:
|
I'm using retrofit + jackson. And I also want to use the same model for the DB and Jackson. But, I'm getting this error. Can someone help me? I don't know where is the error exactly 03-01 20:38:11.462 27759-27759/com E/art: Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 0 free bytes and 0B until OOM" (recursive case)
|
Forget it! @AdamMTGreenberg is right!. I just have to add the following in my model.
|
@anelrh26 like this, is right too! |
Im using retrofit + gson to pull and parse some json from a webservice to this object. Now i want to use that same object as Model but i keep getting stackoverflow.
Is there anyway to fix this?
Here is my model:
The text was updated successfully, but these errors were encountered: