Json2POJOJson2POJO

JSON to POJO Examples

Real-world examples of JSON structures and their corresponding Java POJO classes. Copy, paste, and adapt for your projects.

Convert Your Own JSON
1

Simple User Profile

Basic flat JSON object to Java class

JSON Input
{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "active": true
}
Java POJO Output
public class User {
    private int id;
    private String name;
    private String email;
    private boolean active;
    
    // Getters and setters
}
2

Nested Address Object

JSON with nested objects → multiple Java classes

JSON Input
{
  "name": "John Doe",
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "zipCode": "10001"
  }
}
Java POJO Output
public class User {
    private String name;
    private Address address;
}

public class Address {
    private String street;
    private String city;
    private String zipCode;
}
3

Array of Users (JSON Array)

Root-level array → List<T> in Java

JSON Input
[
  {"id": 1, "name": "Alice"},
  {"id": 2, "name": "Bob"}
]
Java POJO Output
// Use List<User> when parsing
List<User> users = mapper
  .readValue(json, 
    new TypeReference<List<User>>(){});

public class User {
    private int id;
    private String name;
}
4

API Response with Metadata

Paginated API response pattern

JSON Input
{
  "data": [
    {"id": 1, "name": "Product A"}
  ],
  "meta": {
    "page": 1,
    "total": 100
  }
}
Java POJO Output
public class ApiResponse<T> {
    private List<T> data;
    private Meta meta;
}

public class Meta {
    private int page;
    private int total;
}

public class Product {
    private int id;
    private String name;
}
5

Date & Time Fields

ISO-8601 dates → LocalDateTime

JSON Input
{
  "event": "Meeting",
  "startTime": "2025-01-15T09:00:00Z",
  "endTime": "2025-01-15T10:00:00Z"
}
Java POJO Output
public class Event {
    private String event;
    
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
    private LocalDateTime startTime;
    
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
    private LocalDateTime endTime;
}
6

Enum Values

Fixed string values → Java Enum

JSON Input
{
  "orderId": "ORD-123",
  "status": "SHIPPED"
}
Java POJO Output
public class Order {
    private String orderId;
    private OrderStatus status;
}

public enum OrderStatus {
    PENDING,
    PROCESSING,
    SHIPPED,
    DELIVERED
}

Jackson Guide

Deep dive into ObjectMapper configuration and advanced features.

Kotlin Examples

Convert JSON to Kotlin data classes with null safety.

Spring Boot Guide

Use POJOs with @RequestBody in REST controllers.

Have Your Own JSON?

Paste it into our converter and get perfectly formatted Java POJOs in seconds.

Convert JSON Now