[JAVA] Solution de contournement pour com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException

Oublie chaque fois

correct

disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)

    public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

Feature that determines whether encountering of unknown properties (ones that do not map to a property, and there is no "any setter" or handler that can handle it) should result in a failure (by throwing a JsonMappingException) or not. This setting only takes effect after all other handling methods for unknown properties have been tried, and property remains unhandled. Feature is enabled by default (meaning that a JsonMappingException will be thrown if an unknown property is encountered).

erreur

.enable(Feature.IGNORE_UNKNOWN)

Feature that determines what to do if the underlying data format requires knowledge of all properties to output, and if no definition is found for a property that caller tries to write. If enabled, such properties will be quietly ignored; if disabled, a JsonProcessingException will be thrown to indicate the problem. Typically most textual data formats do NOT require schema information (although some do, such as CSV), whereas many binary data formats do require definitions (such as Avro, protobuf), although not all (Smile, CBOR, BSON and MessagePack do not). Note that support for this feature is implemented by individual data format module, if (and only if) it makes sense for the format in question. For JSON, for example, this feature has no effect as properties need not be pre-defined. Feature is disabled by default, meaning that if the underlying data format requires knowledge of all properties to output, attempts to write an unknown property will result in a JsonProcessingException Since: 2.5

Recommended Posts

Solution de contournement pour com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
Solution de contournement pour l'erreur Xcode 12 «Inclure entre guillemets»