So I have a strange issue with a HashMap and not sure how to access the value. I have a HashMap returned to me from an API that is suppose to be HashMap<String, String>. One of the values is actually a LinkedHashMap. I've tried casting it, but since it is a HashMap that is <String, String> it's giving me an error that it's not possible. Is there anyway to get a LinkedHashMap value out of a HashMap that is <String, String>?
I have tried this with no luck: ((HashMap)userInfo.get("key")).get("key");
Could not complete request <java.lang.ClassCastException:
java.util.LinkedHashMap cannot be cast to java.lang.String>java.lang.ClassCastException:
java.util.LinkedHashMap cannot be cast to java.lang.String
This is really ugly looking, but I was actually able to get it out of the HashMap with this:
(HashMap) ((HashMap)((HashMap)userInfo).get("picture")).get("data");
Thanks to Jeroen for sending me down the right path.
geton aLinkedHashMapjust the same...HashMap<String,String>. It shouldn't be possible, unless the library was using a raw type without generics.