๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

JSON๋ณ€ํ™˜2

[JAVA] JSON ๊ฐ์ฒด VO ๋ณ€ํ™˜ ์—๋Ÿฌ : org.codehaus.jackson.map.exc.UnrecognizedPropertyException json ๋ฐ์ดํ„ฐ๋ฅผ vo๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ํ•ด๋‹น ํด๋ž˜์Šค์— ์„ ์–ธ๋˜์ง€ ์•Š์€ ๋ณ€์ˆ˜(ํ”„๋กœํผํ‹ฐ)๊ฐ€ json์— ์žˆ์œผ๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. org.codehaus.jackson.map.exc.UnrecognizedPropertyException ํ•ด๋‹น ํ”„๋กœํผํ‹ฐ๋ฅผ ๋ฌด์‹œํ•˜๊ณ ์ž ํ•˜๋Š” ๊ฒฝ์šฐ @JsonIgnoreProperties(ignoreUnknown = true)๋ฅผ ์„ ์–ธํ•˜๋ฉด ๋œ๋‹ค! @JsonIgnoreProperties(ignoreUnknown = true) public class TestVo { private String userName; private String userId; } json ๋ฐ์ดํ„ฐ๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ๋“ค์–ด์™€๋„ ์ด์ œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค. {"user-name":"name01", "user-id":"id01", "u.. 2021. 12. 9.
[JAVA] JSON ๋ฐ์ดํ„ฐ๋ฅผ VO๋กœ ํŒŒ์‹ฑ, ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ• (json to java class) ๋จผ์ € jackson-databind ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค! spring boot์˜ ๊ฒฝ์šฐ 'spring-boot-starter-web'์— ํฌํ•จ๋˜์–ด ์žˆ์Œ maven com.fasterxml.jackson.core jackson-databind 2.13.0 gradle // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.0' ์œ„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ–ˆ์œผ๋ฉด ์ด ๋‘์ค„๋กœ ์‰ฝ๊ฒŒ ํŒŒ์‹ฑ์ด ๊ฐ€๋Šฅํ•˜๋‹ค! ObjectMapper mapper = new ObjectM.. 2021. 12. 9.
728x90
๋ฐ˜์‘ํ˜•