I have a utility function that returns Map, but that Map always has this structure:
{ \"a\": , \"b\"
Ultimately, because your map has Object as its value type, you need to cast, but you can hide this with a typed utility method:
@SuppressWarnings("unchecked")
public static T get(Map map, String key) {
return (T)map.get(key);
}
So then due to java's type inference this will compile:
Type1 type1obj = get(data, "a");
Adding @SuppressWarnings("unchecked") stops your IDE/compiler complaining about an "unsafe cast".