Here you can find the source of deepMerge(Map
public static Map<String, Object> deepMerge(Map<String, Object> original, Map<String, Object> newMap)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { public static Map<String, Object> deepMerge(Map<String, Object> original, Map<String, Object> newMap) { for (String key : newMap.keySet()) { if (newMap.get(key) instanceof Map && original.get(key) instanceof Map) { Map<String, Object> originalChild = (Map<String, Object>) original.get(key); Map<String, Object> newChild = (Map) newMap.get(key); original.put(key, deepMerge(originalChild, newChild)); } else { original.put(key, newMap.get(key)); }/*from w w w . j a v a 2s. c o m*/ } return original; } }