-
Notifications
You must be signed in to change notification settings - Fork 41
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
Support Nested Models #62
Comments
We should hopefully get this for free once we replace our hand-written JSON parser with a proper library supporting custom annotations - see #61. |
Any updates on this? |
Any updates on this? this would be a crucial feature for many apps |
+1 -- This is absolutely essential to our use-case. |
Any updates on this topic ? It's there another way of doing the same ? |
+1 when is this done?!!!! Using gson ( "com.google.code.gson:gson:2.6.2") and it has done it.. Please let me know thxx |
Until the feature gets added, I've found the potential temporary workaround. I haven't thoroughly tested it yet, but it seems to get me at least part of the way there: public void setMyProperty(Map<String,? extends Object> item) {
RestAdapter adapter = this.getRepository().getAdapter();
ChildTypeRepository repository = adapter.createRepository(ChildTypeRepository.class);
this.myProperty = (ChildModelType) repository.createObject(item);
}
public void setMyListProperty(List<Map<String,? extends Object>> hashList) {
for(Map<String,? extends Object> item : hashList) {
this.myListProperty.add((ThisType) this.getRepository().createObject(item));
}
} By calling the repository |
I'm trying to define a model with an array of models inside it with the Android SDK and I'm struggling with a casting problem from HashMap to my model.
Let's take for example a model called Feed that contains an array of Posts (which is a model also) and a link to the next page (a simple string).
When I try to get a Feed object with a custom static method using the
JsonObjectParser
, it throws an exception that it can't cast HashMap to Post.Right now, the only solution I came up with is to overload the setter of Posts with
ArrayList<HasMap<String, ? extends Object>>
as a parameter instead ofArrayList<Post>
.The text was updated successfully, but these errors were encountered: