I am trying to create a REST web service that returns the details of a user.
Here is my code:
//Actual web service methods implemented from here
@GET
@Path("login/{email}/{password}")
@Produces("application/json")
public Tourist loginUser(@PathParam("email") String email, @PathParam("password") String password) {
List<Tourist> tourists = super.findAll();
for (Tourist tourist : tourists) {
if (tourist.getEmail().equals(email) && tourist.getPassword().equals(password)) {
return tourist;
}
}
//if we got here the login failed
return null;
}
This produces the following JSON:
{
"email": "[email protected]",
"fname": "Adrian",
"lname": "Olar",
"touristId": 1
}
What i need is:
{"tourist":{
"email": "[email protected]",
"fname": "Adrian",
"lname": "Olar",
"touristId": 1
}
}
What would i need to add to my code to produce this?