반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- yum install java
- mac os git error
- Java 1.8
- Medium
- querydsl no sources given
- java 여러개 버전
- error
- springboottest
- maybe not public or not valid?
- easy
- AWS CLI
- parse
- java version
- LeetCode
- java 11
- property or field 'jobparameters' cannot be found on object of type
- log error
- JUnit
- java 1.8 11
- aws
- OpenFeign
- xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
- springboot
- no sources given
- el1008e
- java 버전 변경
- No tests found for given includes
- 스프링부트테스트
- java
- springbatch error
Archives
- Today
- Total
쩨이엠 개발 블로그
@JsonIgnoreProperties - UnrecognizedPropertyException: Unrecognized field , not marked as ignorable (one known property) 본문
개발/JAVA
@JsonIgnoreProperties - UnrecognizedPropertyException: Unrecognized field , not marked as ignorable (one known property)
쩨이엠 2020. 4. 29. 12:55728x90
반응형
Jackson databind시 에러나는경우 UnrecognizedPropertyException이 발생한다
ObjectMapper objectMapper = new ObjectMapper();
Data data = objectMapper.readValue(info, Data.class);
이 때 Unrecognized field , not marked as ignorable (one known property) 에러가 났는데
내 경우에는 Data 객체 안에 info에 대한 필드가 존재 하지 않는 경우였다
파싱하고 싶은 데이터는
{“content”:{“id”:”sensorId_001”,”topic”:”sensor-data-test”},”datainfo”:{“reqTime”:1588126260, “reqId”:1588126395}}
였는데
Data 객체는 Content와 topic밖에 정의가 되어있지 않아 에러가 났다
@Getter
@Setter
public static class Data {
private Content content;
@Getter
@Setter
public static class Content {
private String topic;
}
}
이 땐 ignorable에 대한 어노테이션을 달아주면 된다
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Data {
private Content content;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Content {
private String topic;
}
}
어노테이션을 달아주면 잘 돌아가는 것을 확인 할 수 있다
728x90
반응형
'개발 > JAVA' 카테고리의 다른 글
Input length must be multiple of 16 when decrypting with padded cipher (0) | 2020.05.18 |
---|---|
the request was rejected because no multipart boundary was found error (0) | 2020.05.12 |
SpringBoot Annotation : @ConfigurationProperties (0) | 2020.05.08 |
WAR 파일 배포하기 (0) | 2020.05.01 |
JSON parse error : Cannot deserialize instance of 'java.util.ArrayList' out of START_OBJECT token (0) | 2020.04.30 |
Comments