简体   繁体   中英

what is the equivalent in java of dictionary from.net?

i'm writing a java client for .net server which uses REST/JSON interface. one of the APIs expects a class with a dictionary inside it. i tried to use a hashmap in the java client but seems that the serialization to json is different for java's hashmap and .net dictionary? i'm using gson by the way. is there another object i should use in java? is there a workaround besides coding the serialization myself?

Most people would use HashMap<String, String> , or, for some json purposes, HashMap<String, Object> . The Jackson open source library for parsing JSON in Java will happily deliver these (declared via the interface Map<String, something> where 'something' depends on which Jackson API you use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM