How to ignore unwanted attributes when spring boot deserializes json

encountered a strange problem for several days, only to find that some parameters need to be ignored when deserializing json.
an error occurred when the frontend put update request was made. The chrome debugging error code is as follows:

{"timestamp": 1532181308556, "status": 400, "error": "Bad Request", "exception": "org.springframework.validation.BindException", "errors": [{"codes": ["typeMismatch.mold.customer", "typeMismatch.customer", "typeMismatch.org.sipes.entity.Customer", "typeMismatch"], "arguments": [{"codes": ["mold.customer", "customer"], "arguments": null, "defaultMessage": "customer", "code": "customer"}, "defaultMessage": "Failed to convert property value of type "java.lang.String" to required type" org.sipes.entity.Customer" for property "customer"; Nested exception is java.lang.IllegalStateException: Cannot convert value of type "java.lang.String" to required type" org.sipes.entity.Customer" for property "customer": no matching editors or conversion strategy found "," objectName ":" mold "," field ":" customer "," rejectedValue ":" [object Object] "," bindingFailure ": true," code ":" typeMismatch "}]," message ":" Validation failed for object="mold". " Error count: 1 "," path ":" / mold/mold "}

I"ve been struggling with this problem these days, and tonight I suddenly realized that it was when deserializing that I ignored the customer object.
ask the god, what should I do?

Mar.29,2021

when one object is not enough, another object is created.

suppose your class looks like this:

  

in the definition of the object mold, the getCustomer method is preceded by JsonIgnore, so that it is ignored when parsing json, and this error can be solved.

Menu