18
18
import com .fasterxml .jackson .annotation .JsonInclude ;
19
19
import com .fasterxml .jackson .core .JsonFactory ;
20
20
import com .fasterxml .jackson .core .JsonParseException ;
21
+ import com .fasterxml .jackson .core .JsonProcessingException ;
22
+ import com .fasterxml .jackson .core .ObjectCodec ;
21
23
import com .fasterxml .jackson .databind .JsonMappingException ;
22
24
import com .fasterxml .jackson .databind .JsonNode ;
23
25
import com .fasterxml .jackson .databind .ObjectMapper ;
26
+ import com .fasterxml .jackson .databind .cfg .JsonNodeFeature ;
27
+ import com .fasterxml .jackson .databind .json .JsonMapper ;
24
28
import com .jayway .jsonpath .Configuration ;
25
29
import com .jayway .jsonpath .JsonPath ;
26
30
import com .jayway .jsonpath .spi .json .JacksonJsonNodeJsonProvider ;
@@ -44,19 +48,20 @@ public class EventTemplateHandler {
44
48
45
49
private static final String REGEXP_END_DIGITS = "\\ [\\ d+\\ ]$" ;
46
50
47
- private final Configuration configuration = Configuration .builder ()
48
- .jsonProvider (new JacksonJsonNodeJsonProvider ())
49
- .mappingProvider (new JacksonMappingProvider ())
50
- .build ();
51
+ private ObjectMapper mapper = JsonMapper .builder ()
52
+ .disable (JsonNodeFeature .READ_NULL_PROPERTIES )
53
+ .build ()
54
+ .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
55
+ private Configuration configuration = Configuration .builder ()
56
+ .jsonProvider (new JacksonJsonNodeJsonProvider (mapper ))
57
+ .mappingProvider (new JacksonMappingProvider (mapper ))
58
+ .build ();
51
59
52
60
// eventTemplateParser
61
+ @ JsonInclude (JsonInclude .Include .NON_NULL )
53
62
public JsonNode eventTemplateParser (String jsonData , String eventName ){
54
63
JsonNode updatedJson = null ;
55
- JsonFactory factory = new JsonFactory ();
56
- ObjectMapper mapper = new ObjectMapper (factory );
57
- mapper .setSerializationInclusion (JsonInclude .Include .NON_ABSENT );
58
- mapper .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
59
- mapper .setSerializationInclusion (JsonInclude .Include .NON_NULL );
64
+
60
65
JsonNode rootNode = null ;
61
66
try {
62
67
String eventTemplate = accessFileInSemanticJar (EVENT_TEMPLATE_PATH + eventName .toLowerCase () + ".json" );
0 commit comments