From fc415a644fb8c23dd92bb69b27b00b1740b32f0f Mon Sep 17 00:00:00 2001 From: Alejandro Revilla Date: Tue, 2 Feb 2021 21:00:18 -0300 Subject: [PATCH] add ability to override mapper --- modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java b/modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java index e35ee3f05c..49ba99c451 100644 --- a/modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java +++ b/modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java @@ -43,6 +43,7 @@ public class SendResponse implements AbortParticipant, Configurable { private String contentType; private boolean jsonIncludeNulls= true; private String corsHeader; + public static final String MAPPER = ".mapper"; @Override public int prepare(long id, Serializable context) { @@ -104,7 +105,9 @@ private FullHttpResponse getResponse (Context ctx) { if (response.body() instanceof String) responseBody = String.valueOf(response.body()).getBytes(); else { - ObjectMapper m= jsonIncludeNulls ? mapper : Mapper.getMapperNoNulls(); + ObjectMapper m = ctx.get(MAPPER); + if (m == null) + m = jsonIncludeNulls ? mapper : Mapper.getMapperNoNulls(); responseBody = m.writeValueAsBytes(response.body()); isJson = true; }