Closed shadowdogg closed 6 years ago
@shadowdogg You could use ObjectMapper
class to turn the event received into JSON string. For example,
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
Consumer<Map<String, Object>> consumer = event -> {
StringWriter sw = new StringWriter();
try {
mapper.writeValue(sw, event);
System.out.println(String.format("Received:\n%s", sw.toString()));
} catch (IOException e) {
e.printStackTrace();
}
};
will print
{
"schema" : "ijXO8wCMNFGxuSCA9i_-zw",
"payload" : {
"CreatedById" : "005xx000001T01EAAS",
"CreatedDate" : "2018-02-12T19:31:12Z",
"status__c" : "This is desc 10",
"status2__c" : "No value"
},
"event" : {
"replayId" : 58263
}
}
On workbench it provides the following json:
However on this it provides:
How can it produce Json with all the existing data properly?