Open GoogleCodeExporter opened 8 years ago
Hi folks,
that is my first day using this library and I had the same problem to solve.
client.call() has the returntype Object. But in our case we expect an array of
HashMaps. Unfortunately we cannot cast Object to HashMap[]. (My programm crashed
trying (HashMap[])client.call(...) )
Instead of a directcast to HashMap[] we can do this:
Object[] obj=(Object[]) client.call(...);
for (int i;i<obj.length;i++) {
HashMap<String, String> map= (HashMap<String, String>) obj[i];
}
In my case I have only members of type String in the struct.
Thanks for this library and I hope I can help with this explanation.
Original comment by chm0...@gmail.com
on 20 Mar 2010 at 10:56
Many thanks for taking the time to post this! I'm sure it will help several
people!
Original comment by macko19...@googlemail.com
on 21 Mar 2010 at 6:08
Thanks cjm0815, I'll see if I can roll some kind of wrapper into the next
release.
Original comment by JonTheNiceGuy
on 30 Mar 2010 at 8:24
I'm looking at this, and struggling somewhat to figure out how to add it into
the release. That said, I'm not great at Java, so I don't really know what
other types one might expect to receive over an XMLRPC link that one can
convert into the types within java... so, I don't know what to suggest. Does
anyone have any suggestions?
Original comment by jon@sprig.gs
on 23 Nov 2010 at 9:41
Its not clear to me why an array would cast directly to a HashMap. Structs
certainly would because these are unordered key,value pairings. Arrays are
ordered and don't have key-value pairs...wouldn't a more natural cast be a Java
vector?? So an array of structs would be Vector<HashMap<String,Object>> or some
such. There is only so much you can do though because the nesting isn't really
limited. So you could have an array of structs which have mixed types as
elements, so it will still be up to the user to cast the appropriate type.
If you can handle some of these casts in the library internally it would really
improve the usability.
Original comment by jonefo...@gmail.com
on 10 Dec 2010 at 8:22
Thank you very much you saved my day! :)
Some other tricks?
Original comment by stermi
on 23 Jun 2011 at 12:33
The hashmap solution is working w/ me and it's enough so far.
Original comment by mail.ga...@gmail.com
on 15 Apr 2012 at 7:16
can array two dimension work on this?
exmp array like this:
Array
(
[0] => Array
(
[first_name] => John
[last_name] => Doe
[member_id] => 123435
)
[1] => Array
(
[first_name] => Robert
[last_name] => Brown
[member_id] => 123436
)
)
Original comment by hermawan...@gmail.com
on 4 Apr 2013 at 7:41
Original issue reported on code.google.com by
macko19...@googlemail.com
on 10 Mar 2010 at 6:19Attachments: