Details

Language / Topic
javaJava
Category
Libraries
Source
FasterXML

Rules

balanced
- Use `@JsonProperty` for explicit field name mapping and `@JsonIgnore` to exclude fields — never rely on default field name inference in APIs.
- Configure `ObjectMapper` once and reuse it (thread-safe) — register modules like `JavaTimeModule` for `LocalDate`/`Instant` serialization.
- Use `@JsonCreator` with `@JsonProperty` on constructor params for immutable deserialization — avoid setter-based mapping for value objects.
- Use `@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)` for consistent casing.
- Register `JavaTimeModule` for Java 8+ date/time serialization. Disable `WRITE_DATES_AS_TIMESTAMPS`.
- Use `@JsonCreator` + `@JsonProperty` for immutable object deserialization.
- Configure `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES = false` for forward compatibility.