sql >> Base de Datos >  >> NoSQL >> MongoDB

Respuesta mongodb objectDB en Jersey API-REST

Aquí hay una forma en que podría resolver su problema sin tener que crear el mapeador y, como beneficio adicional, tiene control total sobre la respuesta:

@POST   
@Path("/{sensor_id: [0-9]+}/data")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getSensorsDataById(@PathParam("domain_name") ... ) {
    ...
    List<DBObject> fields = Lists.newArrayList(output.results());
    JSONArray json = new JSONArray();
    for (DBObject field : fields) {
        JSONObject joField = new JSONObject(field.toString());
        json.put(joField);
    }

    return Response.ok().entity(json.toString()).build();
}