Hi i have my web services with Jersey and i use jackson for the generating JSON object i have for example my resource TESTS with set/get method:
public class Tests {
private String name;
private String result;
private String credit;
}
my api:
@Path("/getTests")
@GET
@ManagedAsync
@Produces(MediaType.APPLICATION_JSON)
public void listsTests(@Suspended final AsyncResponse response) {
ListenableFuture<Collection<Esame>> listTests = service
.getTestsInterfaceAsync();
Futures.addCallback(listTests, new FutureCallback<Collection<Tests>>() {
public void onSuccess(Collection<Tests> tests) {
response.resume(tests);
}
public void onFailure(Throwable thrown) {
response.resume(thrown);
}
});
and if i call my api works well, i have this JSON:
{
name=something
result=6
credit=12
}
{
name=something
result=6
credit=12
}
{
name=something
result=6
credit=12
}
{
name=something
result=6
credit=12
}
now my question, if i want to add the status of response? for example:
{
status=200
}
{
name=something
result=6
credit=12
}
i must add Object status in a Tests class?..but in this case the result will be:
{
status=200
name=something
result=6
credit=12
}
{
status=200
name=something
result=6
credit=12
}
try something
public class Result{
private Integer status;
private List<Tests> tests;
// getters and setters
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.