There is no changes in your model class, According to ur JSON info there is
arraylist of Hashmaps.
"foods":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
ArrayList<HashMap<Object,Object>> foodsList =
(ArrayList<HashMap<Object,Object>>) document.getProperty("foods");
User user = new User();
for(HashMap<Object,Object> foodData : foodsList){
Food food = new Food();
food.id = foodsData.get("id");
user.foodsList.add(food);
}
It will be related to something like this, You have to take care about this
thinks while doing parsing the document
On Wednesday, December 2, 2015 at 5:30:02 AM UTC+5:30, brijesh chavda wrote:
>
> I have following document structure.
>
>
> {
> id : "user1",
> "foods":
> [
> { "id": "1001", "type": "Regular" },
> { "id": "1002", "type": "Chocolate" },
> { "id": "1003", "type": "Blueberry" },
> { "id": "1004", "type": "Devil's Food" }
> ]
> }
>
>
> I cant seem to figure out, how to use this in android using couchbase-lite
> for android.
>
> This is my Pojo structure currently , which represents this document.
>
>
> class User{
> private String id;
> private ArrayList<Food> foods;
> }
>
> class Food{
> private String id;
> private String type;
> }
>
> Is this right mapping?
>
>
> Any example link on github is really appreciated.
>
> Thanks,
> Brijesh
>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/e1273e8e-1a34-4b39-949a-1458bae51bbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.