I have a JSON stored in my database, I want to return that json as it is in a jax-rs get service, without using a POJO. Is there any way to do that? I tried just setting it in a String, but the result is escaped. I also tried returning a JSONObject, but I got "org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.json.JSONObject", so I guess I cant use that object type. Finally I used a JSONNode, and it returned my data like this:
{
"nodeType": "OBJECT",
"int": false,
"object": true,
"valueNode": false,
"missingNode": false,
"containerNode": true,
"pojo": false,
"number": false,
"integralNumber": false,
"floatingPointNumber": false,
"short": false,
"long": false,
"double": false,
"bigDecimal": false,
"bigInteger": false,
"textual": false,
"boolean": false,
"binary": false,
"null": false,
"float": false,
"array": false
}
The code.
@GET
@Path("/campanas")
public Response obtenerCampanas(@HeaderParam("Authorization") String sessionId) {
ResponseBase response = new ResponseBase();
int requestStatus = 200;
CampanaResponse campanaResponse = campanasFacade.obtenerCampanas();
response.setData(campanaResponse);
response.setRequestInfo(GlosaCodigoRequest.OPERACION_EXITOSA);
return Response.status(requestStatus).entity(response).build();
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Campanas")
public class CampanaResponse implements Serializable {
private static final long serialVersionUID = -7414170846816649055L;
@XmlElement(name = "campanas", required = true)
private List<Campana> campanas;
@XmlElement(name = "fecha", required = true)
private Date fecha;
//getters.. setters
public static class Campana {
private String idCampana;
private String nombre;
private String urlBanner;
private String global;
private String numeroCuenta;
private Date fechaDonaciones;
private Date fechaInicio;
private Date fechaFin;
private JSONObject config;
//getters..setters
}
}
Is there any way to do that? Thanks.
jax-rs, weblogic 12.1.3