Feed it Java DTO, POJO or record source and get the JSON that Spring Boot's default Jackson setup would most likely produce. Keys come from the declared fields, with @JsonProperty, @JsonIgnore, @JsonIgnoreProperties and the static/transient exclusions applied.
Use it to produce a Swagger example or a sample payload for the frontend from a controller's request or response DTO, or simply to check which keys a Lombok @Data class will emit.
static class, record and enum declarations in the same input so referencing fields are filled with their structure.Root type set to Auto, the class no other class uses as a field type is chosen. When entities reference each other, pick the one you want from the list.@Schema(example = ...), a REST Docs snippet or a MockMvc request body.@Data
@JsonIgnoreProperties({"password"})
public class MemberResponse {
private Long memberId;
@JsonProperty("nick_name")
private String nickname;
private String password;
private Grade grade = Grade.SILVER;
private LocalDate birthDate;
private List<Address> addresses;
private static final long serialVersionUID = 1L;
public enum Grade { BRONZE, SILVER, GOLD }
public record Address(String zipCode, String city, boolean primary) {}
}{
"memberId": 0,
"nick_name": "",
"grade": "SILVER",
"birthDate": "1970-01-01",
"addresses": [
{
"zipCode": "",
"city": "",
"primary": false
}
]
}password is removed by the class-level @JsonIgnoreProperties({"password"}), and the static final serialVersionUID never shows up. The initializer Grade.SILVER is read, so grade is "SILVER" rather than the enum's first constant. The nested record Address expands into an array of objects.
@JsonProperty("x") or @JsonProperty(value = "x").@JsonIgnore fields, keys listed in a class-level @JsonIgnoreProperties({...}), and static or transient fields.record components, nested static class declarations and fields inherited via extends (parent fields first).@JsonProperty("x") on a constant changes the string to x.LocalDateTime → 1970-01-01T00:00:00, LocalDate → 1970-01-01, Instant/OffsetDateTime/ZonedDateTime → ISO string ending in Z, java.util.Date/Timestamp → 1970-01-01T00:00:00.000+00:00.BigDecimal and Long become 0, Optional<T> unwraps to T, byte[] becomes a Base64 string, and UUID and MongoDB ObjectId get well-formed values.List, Set and arrays get one sample element; a map such as Map<Long, V> with a numeric key uses "0", otherwise "key".Hand-written example values drift every time a field is added to a DTO. Generate the JSON from the DTO source and polish the values from there, so no key is missing or misspelled.
Create the request JSON straight from the @RequestBody DTO and paste it into a text block (""") in your test. Keys renamed with @JsonProperty are already applied, matching real binding.
Frontend developers who don't read the backend code get the endpoint's JSON structure directly, instead of having to interpret a Java class.
= "guest", = 100, = true) or an enum constant (= Grade.SILVER); anything else, such as new ArrayList<>() or a method call, falls back to the type's placeholder.getFullName() or boolean isVip(), are added as properties the way Jackson does, honoring @JsonIgnore/@JsonProperty on that getter. Conversely, a private field without a getter is assumed visible (as with Lombok @Getter/@Data).@JsonNaming(SnakeCaseStrategy.class), spring.jackson.property-naming-strategy) and @JsonFormat date patterns are not applied.@JsonValue methods on enums are not evaluated, so such enums still show the constant (or its @JsonProperty name).Page<T>/Slice<T> fields are simplified to an array of elements; real Page serialization is an object with content, pageable and more.@Data or @Getter generates the accessors?Yes. Keys are built from declared fields, so getters and setters that Lombok generates at compile time don't need to be in the source.
LocalDateTime a string and not an array of numbers?Spring Boot registers jackson-datatype-jsr310 and disables WRITE_DATES_AS_TIMESTAMPS by default, which yields ISO strings; the sample follows that default. A bare Jackson ObjectMapper may instead write an array like [1970,1,1,0,0].
Entities have the same field structure, so they parse fine. Bidirectional associations such as @OneToMany would loop, so they are expanded once and then cut off with null or an empty array. There is also a dedicated Spring Boot JPA → JSON page.
@JsonIgnore sits on a setter or on the getter of an existing field?Annotations on a field declaration always apply, and annotations on a getter apply only when no field of that name exists. @JsonIgnore on a setter, or on the getter of a declared field, is not applied, so move it to the field to see its effect.