I have an object in my code of type Object:
Object o
Instance class: Object: o.getClass()provides Object.
Now it should be a card! How can I convert this to a map?
I tried: Map<String, Object> map = (HashMap<String,Object>)o
But this returns: java.lang.ClassCastException: [Ljava.lang.Object; cannot be added to java.util.HashMap
Instance "o" comes from an XMLRPC request. This query incorrectly qualifies variables
Please take a look at this!
EDIT:
Now I have the following problem:
o.getClass().getName()gives java.util.ArrayList,
o.get(0)It gives [Ljava.lang.Object;@739e8329,
and o.get(0).getClass().getName()gives java.lang.String.
I can’t find out what to do.
EDIT2:
Finally I found out what happened. The software that created this object smoothed the data structure into String (valueOf ()). So, when I printed the variable, it returned [Ljava.util.Object, which was actually a string containing this information.Thanks guys!
source
share