如何将两个不同类性的类组合成一个json数据
一个规格1的JSON,一个规格2的JSON,整合成了一个JSON
public static void main(String[] args) {Map<String,List<ErGuige1>> g1map=new HashMap<String,List<ErGuige1>>();Map<String,List<ErGuige2>> g2map= new HashMap<String,List<ErGuige2>>();ErGuige1 g1=new ErGuige1();g1.setGgdm("hh");ErGuige1 g3=new ErGuige1();g3.setGgdm("hh3");List<ErGuige1> list1=new ArrayList<>();list1.add(g1);list1.add(g3);g1map.put("ys",list1);ErGuige2 g2=new ErGuige2();g2.setGgdm("gg");List<ErGuige2> list2=new ArrayList<>();list2.add(g2);g2map.put("cm",list2);Map<String, Object> combinedMap = new HashMap<String, Object>();combinedMap.putAll(g1map);combinedMap.putAll(g2map);System.out.println(combinedMap);}