2017年6月20日

将json字符串映射为java类型

摘要: 如果是简单的java bean,直接解析即可。 ObjectMapper mapper = new ObjectMapper(); Bean bean = mapper.readValue(jsonString, Bean.class); 如果是复杂类型,如list,map,可通过以下两种方法: 方 阅读全文

posted @ 2017-06-20 11:16 箫轩 阅读(2040) 评论(0) 推荐(0) 编辑

java中,将map中的元素按照value值大小排序

摘要: 可以先将map中各元素存放在list中,再对list进行排序。list排序,利用Collections.sort()只要重写compare方法即可。 下面的代码实现按照value值的降序排列。 public static Map<String, Long> sortMap(Map<String, L 阅读全文

posted @ 2017-06-20 11:04 箫轩 阅读(2231) 评论(0) 推荐(0) 编辑

导航