diff --git a/plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/utils/PlaceholderUtils.java b/plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/utils/PlaceholderUtils.java index 9313664f..a0b2a962 100644 --- a/plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/utils/PlaceholderUtils.java +++ b/plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/utils/PlaceholderUtils.java @@ -133,24 +133,21 @@ private static Map jsonCleaner(Map jsonData) { || (value instanceof Map && ((Map) value).isEmpty()) || (value instanceof ArrayList && ((ArrayList) value).isEmpty())) { it.remove(); - } else if (value instanceof Map && !((Map) value).isEmpty()) { - entry.setValue(jsonCleaner((Map) value)); - if (entry.getValue() instanceof Map && ((Map) value).isEmpty() - || (value instanceof ArrayList && ((ArrayList) value).isEmpty())) { + } else if (value instanceof Map) { + value = jsonCleaner((Map) value); + if (((Map) value).isEmpty()) { it.remove(); } - } - if (value instanceof ArrayList) { + } else if (value instanceof ArrayList) { List list = ((ArrayList) value).stream().filter(item -> { if (item == null || (item instanceof String && ((String) item).isEmpty()) || (item instanceof Map && ((Map) item).isEmpty()) || (item instanceof ArrayList && ((ArrayList) item).isEmpty())) { return false; - } else if (item instanceof Map && !((Map) item).isEmpty()) { + } else if (item instanceof Map) { Map parsedArrayItem = jsonCleaner((Map) item); - if (parsedArrayItem instanceof Map && ((Map) parsedArrayItem).isEmpty() - || (parsedArrayItem instanceof ArrayList && ((ArrayList) parsedArrayItem).isEmpty())) { + if (((Map) parsedArrayItem).isEmpty()) { return false; } } @@ -159,9 +156,10 @@ private static Map jsonCleaner(Map jsonData) { if (list.isEmpty()) { it.remove(); } else { - entry.setValue(list); + value = list; } } + entry.setValue(value); } return jsonData; } diff --git a/plugins/rest-plugin/src/test/resources/templates/EmptyObjects.json b/plugins/rest-plugin/src/test/resources/templates/EmptyObjects.json index 1505e07c..7cb62041 100644 --- a/plugins/rest-plugin/src/test/resources/templates/EmptyObjects.json +++ b/plugins/rest-plugin/src/test/resources/templates/EmptyObjects.json @@ -11,6 +11,7 @@ }, "first": "${first}", "second": { }, + "emptyArray": [], "task": [ {