backend/자바
[JAVA] json -> map, map -> json 변환
JaeSung Kim
2021. 1. 22. 15:48
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);