엄지월드

Java에서 List<Model>을 Map<String, Object>로 변경하는 방법 본문

java

Java에서 List<Model>을 Map<String, Object>로 변경하는 방법

킨글 2025. 2. 18. 15:21
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;


ObjectMapper objectMapper = new ObjectMapper();
// items를 List<Map<String, Object>>로 변환
List<Map<String, Object>> collect = items.stream()
    .map(item -> objectMapper.<Map<String, Object>>convertValue(item, new TypeReference<Map<String, Object>>() {}))
    .collect(Collectors.toList());

 

'java' 카테고리의 다른 글

캐시 때문에 css 갱신 안되는 현상 개선  (0) 2024.02.16
DEBUG SMTP: AUTH LOGIN failed  (0) 2022.12.30
java stream 파일 읽기  (0) 2022.12.14
eclipse module import 및 export 방법  (0) 2022.09.30
메서드(Method) 함수(Function) 차이  (0) 2021.03.14
Comments