jackson json轉實體 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyExceptionhtml
jackson 2.2.2java
因爲vo中缺乏json的某個字段屬性引發json
3種解決方法數組
一、 vo中添加註解 @JsonIgnoreProperties(ignoreUnknown = true),在實體類上加上註解app
二、 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);post
三、 添加以下便可:mapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);,把空的數組「[]」轉爲空url
com.fasterxml.jackson.databind.exc.MismatchedInputExceptionspa
錯誤的格式code
[{ "firstName": "hgf", "lastName": "frew", "username": "erf", "email": "bgghjk", "password": "bgte", "role": "trrere" } ]
正確的格式,不要[]xml
{
"firstName": "hgf", "lastName": "frew", "username": "erf", "email": "bgghjk", "password": "bgte", "role": "trrere" }