Json字符串转换Map类型

今天在Json转换为Map类型这里遇到个小问题,卡了很久,最后在网上找到了答案,在此记录一下:

我自定义了一个模型类,这里暂且叫Temp.java,数据保存格式为HashMap<String,Temp>  hashmap。

Map转Json:

String json = JSON.toJSONString(hashmap);

Json转Map:

HashMap<String,Temp> hashmap = (HashMap<String,Temp>) JSON.parseObject(json,new TypeReference<HashMap<String,Temp>>(){});


如有错误,烦请各位大神不吝赐教

猜你喜欢

转载自blog.csdn.net/asd501823206/article/details/70568767