I have following json response from webservice using retrofit 2.0 library. As retrofit uses Gson by default internally to map json into Java objects.
[
{
"album-96": {
"id": 96,
"m_id": 1,
"user_id": null,
"p_id": null,
"category_id": 1,
"sub_category_id": 12,
"country_id": 226,
"menu_id": null,
"name": "Kate Gosselin Photos",
"old_name": "Kate Gosselin Photos",
"meta_description": "Katie Irene "Kate" Gosselin is an American television personality",
"meta_keywords": "Television, Personality",
"tags": "",
"description": "<p>Katie Irene "Kate" Gosselin is an American television personality</p>",
"total_file": 18,
"view": 330,
"url_str": "kate-gosselin-photos-96",
"url": "/album/kate-gosselin-photos-96",
"custom_url": "/album/96/kate-gosselin-photos",
"old_url": "kate-gosselin-photos-96.html",
"created_date": 1440843034,
"update_date": 1440866729,
"old": "no",
"status": "publish",
"c_id": 226,
"c_name": "United States",
"c_url": "united-states",
"ca_id": 1,
"ca_name": "Actress",
"ca_url": "actress",
"sca_id": 12,
"sca_categories_id": 1,
"sca_name": "Television",
"sca_url": "television",
"array": [
{
"id": 5359,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate Gosselin",
"name": "5359.jpg",
"custom_url": "/photo/5359/kate-gosselin"
},
{
"id": 5358,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate Gosselin",
"name": "5358.jpg",
"custom_url": "/photo/5358/kate-gosselin"
},
{
"id": 5357,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate Gosselin",
"name": "5357.jpg",
"custom_url": "/photo/5357/kate-gosselin"
},
{
"id": 5356,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate gosselin",
"name": "5356.jpg",
"custom_url": "/photo/5356/kate-gosselin"
},
{
"id": 5355,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate Gosselin hair",
"name": "5355.jpg",
"custom_url": "/photo/5355/kate-gosselin-hair"
},
{
"id": 5354,
"album_path": "/site-content/albums/Kate-Gosselin-Photos/",
"title": "Kate gosselin",
"name": "5354.jpg",
"custom_url": "/photo/5354/kate-gosselin"
}
]
},
"album-95": {
"id": 95,
"m_id": 1,
"user_id": null,
"p_id": null,
"category_id": 4,
"sub_category_id": 6,
"country_id": 226,
"menu_id": null,
"name": "Christina Maria Aguilera",
"old_name": "Christina Maria Aguilera",
"meta_description": "Christina María Aguilera is an American singer, songwriter, and actress. Born in Staten Island, New York and raised in Rochester and Wexford, Pennsylvania",
"meta_keywords": "Christina Maria Aguilera",
"tags": "",
"description": "<p>Christina Mar&iacute;a Aguilera is an American singer, songwriter, and actress. Born in Staten Island, New York and raised in Rochester and Wexford, Pennsylvania</p>",
"total_file": 45,
"view": 466,
"url_str": "christina-maria-aguilera-95",
"url": "/album/christina-maria-aguilera-95",
"custom_url": "/album/95/christina-maria-aguilera",
"old_url": "christina-maria-aguilera-95.html",
"created_date": 1435346180,
"update_date": 1435346329,
"old": "no",
"status": "publish",
"c_id": 226,
"c_name": "United States",
"c_url": "united-states",
"ca_id": 4,
"ca_name": "Music",
"ca_url": "music",
"sca_id": 6,
"sca_categories_id": 4,
"sca_name": "Singer",
"sca_url": "singer",
"array": [
{
"id": 5334,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5334.jpg",
"custom_url": "/photo/5334/christina-aguilera"
},
{
"id": 5333,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5333.jpg",
"custom_url": "/photo/5333/christina-aguilera"
},
{
"id": 5332,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5332.jpg",
"custom_url": "/photo/5332/christina-aguilera"
},
{
"id": 5331,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5331.jpg",
"custom_url": "/photo/5331/christina-aguilera"
},
{
"id": 5330,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5330.jpg",
"custom_url": "/photo/5330/christina-aguilera"
},
{
"id": 5329,
"album_path": "/site-content/albums/Christina-Maria-Aguilera/",
"title": "Christina Aguilera",
"name": "5329.jpg",
"custom_url": "/photo/5329/christina-aguilera"
}
]
}
}
]
I have used http://www.jsonschema2pojo.org/ to generate model classes for my json. But it does not return me the list of items in Arraylist. Following is my code
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://girlvalue.com")
.addConverterFactory(GsonConverterFactory.create())
.build();
GirlValueAPI girlValueAPI = retrofit.create(GirlValueAPI.class);
Call<AlbumsList> call = girlValueAPI.loadAlbums("android");
call.enqueue(this);
What should be model classes for above json response?