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,21 @@ 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_ABSENT )
55
+ .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
56
+ private Configuration configuration = Configuration .builder ()
57
+ .jsonProvider (new JacksonJsonNodeJsonProvider (mapper ))
58
+ .mappingProvider (new JacksonMappingProvider (mapper ))
59
+ .build ();
51
60
52
61
// eventTemplateParser
62
+ @ JsonInclude (JsonInclude .Include .NON_NULL )
53
63
public JsonNode eventTemplateParser (String jsonData , String eventName ){
54
64
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 );
65
+
60
66
JsonNode rootNode = null ;
61
67
try {
62
68
String eventTemplate = accessFileInSemanticJar (EVENT_TEMPLATE_PATH + eventName .toLowerCase () + ".json" );
0 commit comments