#java java Json data[ {"uid":"1","name":"阿花","age":38,"gender":"F"}, {"uid":"2","name":"阿瓜","age":28,"gender":"M"}] Entity@Data@JsonInclude(JsonInclude.Include.NON_NULL)@JsonPropertyOrder(value = { "uid", "name", "age", "gender"})public class Customer { // creativeId equals adId @JsonProperty("uid") private String uid; @JsonProperty("name") private String name; @JsonProperty("age") private Integer age; @JsonProperty("gender") private String gender;} Test@Testpublic void test() throws IOException { List<Customer> customerList = objectMapper.readValue(json, new TypeReference>() {}); Map customerMap = customerList.stream() .collect(Collectors.toMap( Customer::getUid, // key customer -> customer)); // value System.out.println(objectMapper.writeValueAsString(customerMap));} Output{ "1": { "uid": "1", "name": "阿花", "age": 38, "gender": "F" }, "2": { "uid": "2", "name": "阿瓜", "age": 28, "gender": "M" }} Comments: Please enable JavaScript to view the comments powered by Disqus.