added generic data object

This commit is contained in:
Carl Bingel 2020-02-16 16:36:26 +01:00
parent 78b968f0d3
commit a29e34f2c6

View file

@ -21,6 +21,7 @@ public class JsonEvtLoopStatusReport {
public String status; public String status;
public String message; public String message;
public JsonMessageEnvelope envelope; public JsonMessageEnvelope envelope;
public JsonNode data;
/** /**
@ -35,6 +36,13 @@ public class JsonEvtLoopStatusReport {
this.reqID = null; this.reqID = null;
} }
public JsonEvtLoopStatusReport( String respType, JsonNode reqID, JsonNode data) {
this.respType = respType;
this.status = "ok";
this.reqID = reqID;
this.data = data;
}
/** /**
* Creates new JsonEvtLoopStatusReport object to use for responding to requests * Creates new JsonEvtLoopStatusReport object to use for responding to requests
* *
@ -70,7 +78,11 @@ public class JsonEvtLoopStatusReport {
ObjectMapper mpr = new ObjectMapper(); ObjectMapper mpr = new ObjectMapper();
mpr.setVisibility( PropertyAccessor.FIELD, Visibility.ANY); mpr.setVisibility( PropertyAccessor.FIELD, Visibility.ANY);
try { try {
System.out.println( mpr.writeValueAsString(this)); //System.out.println( mpr.writeValueAsString(this));
JsonNode n = mpr.valueToTree(this);
System.out.println( mpr.writeValueAsString(n));
} catch( IllegalArgumentException e) {
System.err.println( "JsonEvtLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
} catch( JsonProcessingException e) { } catch( JsonProcessingException e) {
System.err.println( "JsonEvtLoopStatusReport: ERROR: Failed to serialize object: " + e.toString()); System.err.println( "JsonEvtLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
} }