79266315

Date: 2024-12-09 20:08:14
Score: 0.5
Natty:
Report link

I was able to figure out a woking solution

public static List<Map<String, Object>> cleanJsonData(List<Map<String, Object>> parsedJsonChildData, List<Map<String, Object>> parsedXmlChildData) { List<Map<String, Object>> modifiedParsedJsonChildData = new ArrayList<>();

    for (int i = 0; i < parsedJsonChildData.size(); i++) {
        Map<String, Object> jsonItem = parsedJsonChildData.get(i);
        Map<String, Object> xmlItem = parsedXmlChildData.get(i);

        Map<String, Object> filteredItem = new HashMap<>();
        for (Map.Entry<String, Object> entry : jsonItem.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();


            if ((value != null && !value.toString().isEmpty()) || xmlItem.containsKey(key)) {
                filteredItem.put(key, value);
            }
        }
        modifiedParsedJsonChildData.add(filteredItem);
    }

    return modifiedParsedJsonChildData;


}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Beginercoder