Search code examples
javapythonmatlabhashmapxml-rpc

How to process [Ljava.lang.object in hashmap from XML-RPC in Matlab?


I'm trying to use the Apache XML-RPC Java client into Matlab, in combination with a python SimpleXMLRPCserver.

From the python server, I try to return a dictionary that is linking strings with lists, juts like the following:

return {'node15': [12,58748], 'node34': [28,45784]}

Then when calling the method from the maltab client, I end up with what matlab calls a hashmap:

{'node15' = [Ljava.lang.Object;@6f02ae95, node34 = [Ljava.lang.Object;@1913f123}

I didn't find a way to extract my list into arrays, my next step was to use values() to extract them, but it only returns a "HashMap$Values" list containing this:

[ [Ljava.lang.Object;@6f02ae95, [Ljava.lang.Object;@1913f12]

It looks like matlab failed to translate the java structure into something it understands.

Any idea what to do with this ?


Solution

  • You need to convert it to array first, then you can use cell to cast to Matlab native types:

    cell(myHashMap.values().toArray());