I have the following JSON channel:
{
collection_name: "My First Collection",
username: "Alias",
collection: {
1: {
photo_id: 1,
owner: "Some Owner",
title: "Lightening McQueen",
url: "http://hesp.suroot.com/elliot/muzei/public/images/randomhash1.jpg"
},
2: {
photo_id: 2,
owner: "Awesome Painter",
title: "Orange Plane",
url: "http://hesp.suroot.com/elliot/muzei/public/images/randomhash2.jpg"
}
}
}
What I'm trying to do is get the contents of the collection - photo_id, owner, title and URL. I have the following code, however, I am getting GSON JSON errors:
@GET("/elliot/muzei/public/collection/{collection}")
PhotosResponse getPhotos(@Path("collection") String collectionID);
static class PhotosResponse {
List<Photo> collection;
}
static class Photo {
int photo_id;
String title;
String owner;
String url;
}
}
I thought my code was right to get the JSON channel, but I'm not sure. Any help was appreciated.
The error I am getting is:
Caused by: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 75
However, I'm struggling to figure out how to use the GSON library
K20GH source
share