Java Json String -> List 변환 error

Jinmin Kim·2023년 9월 13일

front에서 json.stringfiy로 데이터를 보내고
해당 데이터를 back에서 string을 다시 list로 변환 하는 작업이 필요하였다.

"[{"a":"1", "b":"2", "c":"3"}]"

위의 데이터를 받아서 변환을 하는데 계속

[{a:1, b:2, c:3}]

위와 같이 변환이 되어서 확인끝에

"[{\"a\":\"1\", \"b\":\"2\"]"

이렇게 보내야 아래의 코드를 사용했을때 정상적으로 List로 변환되는것을 확인할수있었다.

		List<HashMap> list = null;
		ObjectMapper mapper = new ObjectMapper();
		
		try {
			list = mapper.readValue(str, new ArrayList<HashMap<String, Object>>().getClass());
		} catch (Exception e) {
			logger.debug("" + e);
		}
profile
Let's do it developer

0개의 댓글