protected static JsonNode mergeJsonNodes(JsonNode nodeTobeUpdate, JsonNode sourceNode) {

        Iterator<String> fieldNames = sourceNode.fieldNames();

        while (fieldNames.hasNext()) {
            String sourceFieldName = fieldNames.next();
            JsonNode fieldToBeUpdated = nodeTobeUpdate.get(sourceFieldName);
            JsonNode sourceValue = sourceNode.get(sourceFieldName);

            // If the node is an @ArrayNode
            if (fieldToBeUpdated != null && fieldToBeUpdated.isArray() && sourceValue.isArray()) {
                // running a loop for all elements of the updated ArrayNode
                for (int i = 0; i < sourceValue.size(); i++) {
                    JsonNode updatedChildNode = sourceValue.get(i);
                    // Create a new Node in the node that should be updated, if there was no
                    // corresponding node in it
                    // Use-case - where the updateNode will have a new element in its Array
                    if (fieldToBeUpdated.size() <= i) {
                        ((ArrayNode) fieldToBeUpdated).add(updatedChildNode);
                    }
                    // getting reference for the node to be updated
                    JsonNode childNodeToBeUpdated = fieldToBeUpdated.get(i);
                    mergeJsonNodes(childNodeToBeUpdated, updatedChildNode);
                }
            }
            // if the Node is an @ObjectNode
            else if (fieldToBeUpdated != null && fieldToBeUpdated.isObject()) {
                mergeJsonNodes(fieldToBeUpdated, sourceValue);
            }
            // do the replacement
            else {
                if (nodeTobeUpdate instanceof ObjectNode) {
                    ((ObjectNode) nodeTobeUpdate).replace(sourceFieldName, sourceValue);
                }
            }
        }
        return nodeTobeUpdate;
    }
Replaces the values from the source node into the nodeToBeUpdated.
ache/src/main/java/achecrawler/config/Configuration.java