MultiValueMap的序列化以及反序列化

来源:互联网 发布:c语言什么时候用void 编辑:程序博客网 时间:2024/06/06 04:01

1、序列化

包:org.apache.commons.collections.map

        MultiValueMap result = new MultiValueMap();        result.put("2017", 11);        result.put("2017", 12);        result.put("2018", 1);        System.out.println(new Gson().toJson(result));


2、反序列化

包:org.springframework.util

        LinkedMultiValueMap<String,Integer> map = new Gson().fromJson(resultStr, new TypeToken<LinkedMultiValueMap<String,Integer>>(){}.getType());