Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
clicman committed Dec 3, 2021
1 parent 7cc9f60 commit b148159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,21 @@ private static Map<String, Object> jsonCleaner(Map<String, Object> 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<String, Object>) value));
if (entry.getValue() instanceof Map && ((Map<?, ?>) value).isEmpty()
|| (value instanceof ArrayList && ((ArrayList<?>) value).isEmpty())) {
} else if (value instanceof Map) {
value = jsonCleaner((Map<String, Object>) 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<String, Object> parsedArrayItem = jsonCleaner((Map<String, Object>) item);
if (parsedArrayItem instanceof Map && ((Map<?, ?>) parsedArrayItem).isEmpty()
|| (parsedArrayItem instanceof ArrayList && ((ArrayList<?>) parsedArrayItem).isEmpty())) {
if (((Map<?, ?>) parsedArrayItem).isEmpty()) {
return false;
}
}
Expand All @@ -159,9 +156,10 @@ private static Map<String, Object> jsonCleaner(Map<String, Object> jsonData) {
if (list.isEmpty()) {
it.remove();
} else {
entry.setValue(list);
value = list;
}
}
entry.setValue(value);
}
return jsonData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"first": "${first}",
"second": { },
"emptyArray": [],
"task": [
{

Expand Down

0 comments on commit b148159

Please sign in to comment.