@Override @SuppressWarnings("unchecked") public Map<String, List<MenuItemDescription>> decodeMenuItemsMap(String json) throws FormEncodingException { JsonObject jsonObj = new JsonParser().parse(json).getAsJsonObject(); Map<String, Object> dataMap = asMap(jsonObj); Map<String, List<MenuItemDescription>> retval = null; if (dataMap != null) { retval = new HashMap<String, List<MenuItemDescription>>(); for (Map.Entry<String, Object> entry : dataMap.entrySet()) { List<MenuItemDescription> itemsList = new ArrayList<MenuItemDescription>(); String key = entry.getKey(); Object obj = entry.getValue(); if (obj != null) { List<Object> itemsMapList = (List<Object>) obj; for (Object itemObj : itemsMapList) { Map<String, Object> itemDescMap = (Map<String, Object>) itemObj; MenuItemDescription desc = new MenuItemDescription(); desc.setDataMap(itemDescMap); itemsList.add(desc); } } retval.put(key, itemsList); } } return retval; }
@Override @SuppressWarnings("unchecked") public Map<String, List<MenuItemDescription>> decodeMenuItemsMap(String json) throws FormEncodingException { JsonObject jsonObj = new JsonParser().parse(json).getAsJsonObject(); Map<String, Object> dataMap = asMap(jsonObj); Map<String, List<MenuItemDescription>> retval = null; if (dataMap != null) { retval = new HashMap<String, List<MenuItemDescription>>(); for (Map.Entry<String, Object> entry : dataMap.entrySet()) { List<MenuItemDescription> itemsList = new ArrayList<MenuItemDescription>(); String key = entry.getKey(); Object obj = entry.getValue(); if (obj != null) { List<Object> itemsMapList = (List<Object>) obj; for (Object itemObj : itemsMapList) { Map<String, Object> itemDescMap = (Map<String, Object>) itemObj; MenuItemDescription desc = new MenuItemDescription(); desc.setDataMap(itemDescMap); itemsList.add(desc); } } retval.put(key, itemsList); } } return retval; }