json -> map 변환
import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = mapper.readValue(jsonStr, Map.class);
map -> json 변환
import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(map);
json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
'backend > 자바' 카테고리의 다른 글
| [JAVA] 문자열 체크 (0) | 2021.05.14 |
|---|---|
| [JAVA] [CONVERT] 형변환 (0) | 2021.05.14 |
| [JAVA] 문자 대소문자로 변환 (0) | 2021.04.28 |
| [JAVA] String -> String[] 만들기 (0) | 2021.01.22 |
| [JAVA] 몇번째 문자열 바꾸는 기능 (0) | 2019.02.12 |