Jackson and REST Android Annotations: Deserialize JSON Array of Objects
I have a REST service which returns data that looks like this:
[
{ bookmark object json here },
{ bookmark object json here },
{ bookmark object json here },
...
]
My REST client class looks like this:
@Rest(rootUrl = Constants.ApiConfig.API_ROOT, converters =
{MappingJackson2HttpMessageConverter.class})
public interface RestApiClient {
@Get("/bookmark/read?id={identifier}")
public BookmarkList getBookmarks(String identifier);
}
BookmarkList looks like this:
public class BookmarkList {
List<Bookmark> bookmarks;
@JsonValue
public List<Bookmark> getBookmarks() {
return bookmarks;
}
@JsonCreator
public void BookmarkList(@NotNull List<Bookmark> bookmarks) {
this.bookmarks = bookmarks;
}
}
However, when I utilize this setup, I get the following error:
Could not read JSON: Can not deserialize instance of
com.whatever.entity.BookmarkList out of START_ARRAY token
What I want is something like the EventList example at
https://github.com/excilys/androidannotations/wiki/Rest-API#get, but that
doesn't seem to work for me out of the box.
Is there a way to get this working?
No comments:
Post a Comment