I am trying to return multiple objects (such as String, Boolean, MyOwnClass, etc) from a Java REST API Method using JAX-RS in Eclipse.
Here's what I have right now:
My API Method
@Path("/")
public class myAPI {
@GET
@Produces({ "application/xml", "application/json" })
@Path("/getusers")
public Response GetAllUsers() {
//Data Type #1 I need to send back to the clients
RestBean result = GetAllUsers();
//Data Type #2 I need to send with in the response
Boolean isRegistered = true;
//The following code line doesn't work. Probably wrong way of doing it
return Response.ok().entity(result, isRegistered).build();
}
}
RestBean class:
public class RestBean {
String status = "";
String description = "";
User user = new User();
//Get Set Methods
}
So I'm basically sending two data types: RestBean and Boolean.
What's the right way of sending back a JSON response with multiple data objects?
Boolean isRegistered = "true";is a compile error. A string "true" is not a Boolean.