Reputation: 873
I'm receiving json from an API with article objects which include an array of images for that article. Take a look.
I'm using retrofit with gson to convert the data to Java objects.
These objects extend RealmObject, so they can be saved to realm immediately.
I use copyToRealmOrUpdate for saving the received objects to realm.
The articles are perfectly stored, but the images aren't although they are in the returned retrofit objects.
It seems like they aren't persisted automatically.
Do I need to loop over those articles and then copyToRealmOrUpdate the images array?
Then simply call setImages() with the images RealmList?
What's the best way to solve this problem?
Let me know if you need more information. I'm currently on my mobile and could give you later more.
Upvotes: 2
Views: 1016
Reputation: 1651
The problem seems to be that in the JSON string "images" is not an array of image objects, but it's a "data" object which itself is in turn an array of image objects.
Do you have control over the JSON format or is it just something you receive and have no control over?
Upvotes: 1