Leonidus
Leonidus

Reputation: 448

conversion object to dictionary in `Java`

conversion of an XMLRPC object to dictionary in Java

I have an object obj={6=Coffee, 2=[Cocoa,icecream], 1=Chocolate} and I want to convert this to a dictionary so that I can have key as 6, 2, 1 and values 'Coffee', 'Cocoa' and 'Chocolate'. How can I do this ? any pointers would be appreciated.

Object obj was returned by method of XMLRPC execute("execute", params);

Upvotes: 0

Views: 1840

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074365

In Java, "dictionaries" are called Maps. Refer to the various interfaces and implementations in java.util. The main interface you'd probably want is Map. Which implementation you want (HashMap, et. al.) will depend on how you're using it. How you convert whatever it is you're starting with into a Map depends entirely on what you have to start with.

Upvotes: 1

Related Questions