I want to send Json with Jersey. I use mongoDb.
My function to return my objects :
public static List<DBObject> getAll(){
List<DBObject> toReturn = new ArrayList<DBObject>();
DBCollection coll = Db.databse.getCollection("Roles");
DBCursor cursor = coll.find();
try {
while(cursor.hasNext()) {
toReturn.add(cursor.next());
}
} finally {
cursor.close();
}
return toReturn;
}
And my jersey method to return json :
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getAll(){
return Response.status(200).entity(Role.getAll()).build();
}
I use POSTMAN. POSTMAN receives 200 but not my JSON. If somebody can help me. Thx.