}
private Map<String, Object> handleJsonObject(final JsonElement jsonElement) {
- final Map<String, Object> jsonObjectAsMap = new HashMap<>();
final JsonObject jsonObject = jsonElement.getAsJsonObject();
+ if (jsonObject.entrySet().isEmpty()) {
+ return null;
+ }
+ final Map<String, Object> jsonObjectAsMap = new HashMap<>();
for (final Entry<String, JsonElement> entry : jsonObject.entrySet()) {
- jsonObjectAsMap.put(entry.getKey(), handleComplexJsonValue(entry.getValue()));
+ final Object value = handleComplexJsonValue(entry.getValue());
+ if (value != null) {
+ jsonObjectAsMap.put(entry.getKey(), value);
+ }
+
}
- return jsonObjectAsMap;
+ return jsonObjectAsMap.isEmpty() ? null : jsonObjectAsMap;
}
private List<Object> handleJsonArray(final JsonElement entry) {