JSON to Java
The result appears here.
Generate
Your document never leaves the browser.
Java records with Jackson annotations, from a JSON sample — in your browser.
Paste the JSON your service sends or receives and get Java types Jackson can bind it to. The default is a record per object, for Java 17 and later; classes with getters and setters are there for older code.
Each object becomes a record, and each record carries @JsonIgnoreProperties(ignoreUnknown = true), so a field added to the API later does not break deserialisation. Keys in snake_case become camelCase components with @JsonProperty holding the wire name, so order_id is the component orderId.
A key present and never null in every record becomes a primitive: qty is long, price is double. gift-wrap is missing from one line item, so it becomes the boxed Boolean, which can hold the null Jackson assigns to a missing key. The comment at the top of the file says so, in the terms Jackson uses.
The sample, an order with two line items, pasted as the source
{
"order_id": 1042,
"placed_at": "2026-09-25T10:15:00Z",
"paid": true,
"customer": { "name": "Ada Lovelace", "email": "ada@example.com" },
"items": [
{ "sku": "PEN-01", "qty": 2, "price": 3.5, "note": null },
{ "sku": "INK-07", "qty": 1, "price": 12, "note": "Fragile", "gift-wrap": true }
]
}The records written for it
// Generated by myjsoneditor.com for Jackson 2.15+ (Java 17+).
// A missing key and a null both read as null; a primitive (long, double, boolean) is never
// absent or null in the document, so it has no null to hold.
// Types other than the root are package-private: move each to its own file to use it from another package.
package generated;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
record Customer(
String name,
String email
) {}
@JsonIgnoreProperties(ignoreUnknown = true)
record Item(
String sku,
long qty,
double price,
String note,
@JsonProperty("gift-wrap") Boolean giftWrap
) {}
@JsonIgnoreProperties(ignoreUnknown = true)
public record Root(
@JsonProperty("order_id") long orderId,
@JsonProperty("placed_at") String placedAt,
boolean paid,
Customer customer,
List<Item> items
) {}An order id and a flag
{ "order_id": 1042, "paid": true }With Shape Class with getters and setters
// Generated by myjsoneditor.com for Jackson 2.15+ (Java 8+).
// A missing key and a null both read as null; a primitive (long, double, boolean) is never
// absent or null in the document, so it has no null to hold.
package generated;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class Root {
@JsonProperty("order_id")
private long orderId;
private boolean paid;
public long getOrderId() { return orderId; }
public void setOrderId(long orderId) { this.orderId = orderId; }
public boolean getPaid() { return paid; }
public void setPaid(boolean paid) { this.paid = paid; }
}Option
Shape: Record (Java 17+), the default, or Class with getters and setters, which targets Java 8 and marks the fields for Jackson with @JsonAutoDetect.
Option
Package: generated by default. Type your own package name and the declaration follows it.
Option
Ignore unknown properties: on by default. Turn it off when a new key in the payload should fail loudly rather than be skipped.
Nested records are named from the keys that hold them, with a list’s elements in the singular. An integer too large for long, such as a 20-digit account number, becomes BigInteger, which Jackson reads without losing a digit. A field that mixes types, or holds nothing but null in the sample, becomes JsonNode, with a comment naming what was seen, so you can pick the type yourself.
Only the root type is public. The others are package-private so the whole output fits in one file; move each to a file of its own when it is needed from another package. Keywords and names starting with a digit are adjusted too, so class becomes class_ and 2fa becomes _2Fa, each with its wire name kept in @JsonProperty.
A 20-digit account number, a null and a keyword
{ "account": 12345678901234567890, "note": null, "class": "A" }BigInteger, JsonNode and class_, each with a comment
// Generated by myjsoneditor.com for Jackson 2.15+ (Java 17+).
// A missing key and a null both read as null; a primitive (long, double, boolean) is never
// absent or null in the document, so it has no null to hold.
package generated;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import java.math.BigInteger;
@JsonIgnoreProperties(ignoreUnknown = true)
public record Root(
BigInteger account, // past long — Jackson reads it exactly
JsonNode note, // only null was seen
@JsonProperty("class") String class_
) {}Inference and code generation both run inside this browser tab. The sample is never uploaded, stored on a server or logged, because the page has no server to send it to, and once loaded it carries on working with the connection off.
Jackson 2.15 or later, as the header comment says. Records need at least 2.12.
Not directly. The annotations are Jackson’s; Gson uses @SerializedName for the same job, and its record support is newer.
A sample cannot promise that a number will stay under two billion, so whole numbers use long. Narrow it to int where you know the range.