I'm writing a framework for a web service api that return json. I use Jackson library to deserialize the json string. The api return a property to continue fetching the result of request. The response like this:
{
continueToken:"token",
results: [
{
},
]
}
All the responses have this structure. The only problem is that the name of the continue property differ from request to another. The name is like this
prefix + "continue"
I want to create only one class and to be able to map the json to this class. How can I do that? Here's what I want to have:
public class Response {
private String continueToken;
private List<Article> results;
public Response (String continueToken, Article[] articles) {
this.continueToken = continueToken;
this.results = Arrays.asList(articles);
}
}
//Here the name is ttcontinue
String json = request.get(type1);
Response r = jsonToResponse(json);
//Here the name is llcontinue
json = request.get(type2);
r = jsonToResponse(json);