When the JSON string is transferred from the foreground to the background, the following exception message appears:
unrecognized field “pager. PageSize” (class XXXXX. Alxxxbean), not marked as ignorable
the reason is that the JSON string passed in the foreground contains attributes that the target Java entity class does not have
The solutions are as follows:
1. @ jsonignoreproperties (ignoreunknown = true)
add annotation to the corresponding entity class to indicate that the attribute that does not exist in the target object can be ignored,
the annotation belongs to import org.codehaus.jackson.annotate.jsonignoreproperties
— the method is feasible
2. Format the input content to ensure that the incoming JSON string does not contain the attributes of the target object
3. Global deserialization feature configuration
objectMapper.configure(DeserializationFeature.FAIL_ ON_ UNKNOWN_ PROPERTIES,false);
when the objectmapper is configured to deserialize, it ignores the attributes that the target object does not have. You will have this feature whenever you use the objectmapper to deserialize
– this method has not been tested
Similar Posts:
- SpringMVC @RequestBody Error:Unrecognized field, not marked as ignorable
- [Solved] com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “FileSi…
- @Jsonignoreproperties does not work [How to Solve]
- [Solved] Java.io.EOFException: No content to map to Obje…
- Error reporting from objectmapper nested JSON to object
- [Solved] com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): ha
- Postman passing Josn field error: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_STRING token
- [Solved] java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
- [Solved] TypeError: string indices must be integers, not str