JAVA

ObjectMapper사용하여 json을 vo에 담기

개발자 배찌 2023. 11. 6. 15:23
728x90

var paramList = [];
var testInfo = {};

testInfo.mbrSqno = 1
testInfo.mbrNm = ‘배지똥’

paramList.push(testInfo);

var paramListJson = JSON.stringify(paramList);


controller단
@RequestParam String paramListJson

paramListJson = paramListJson.replaceAll(“"”, “\””);
ObjectMapper om = new ObjectMapper();
List<InfoVO> infoList = om.readValue(paramListJson, om.getTypeFactory().constructCollectionType(List.class, InfoVO.class));

List<InfoVO> infoList = om.readValue(paramListJson, new TypeReference<InfoVO>(){});