Generate Java POJOs for the Stripe Customer Object

Convert a Stripe Customer JSON response into Java POJOs with snake_case mapping, nested address, and metadata Map handling.

Real-world

Detailed Explanation

Stripe Customer → Java

Stripe's Customer object is a representative example of a financial API response: deeply nested, snake_case keys, mixed required/nullable fields, and an extensible metadata map for user-defined data.

Sample Payload (abridged)

{
  "id": "cus_NffrFeUfNV2Hib",
  "object": "customer",
  "balance": 0,
  "created": 1680893993,
  "currency": "usd",
  "default_source": null,
  "delinquent": false,
  "description": null,
  "email": "jenny.rosen@example.com",
  "name": "Jenny Rosen",
  "phone": null,
  "address": {
    "city": "South San Francisco",
    "country": "US",
    "line1": "354 Oyster Point Blvd",
    "postal_code": "94080"
  },
  "metadata": { "internal_user_id": "u_42" },
  "tax_exempt": "none"
}

Generated POJO Hierarchy

package com.example.stripe;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

public class Customer {
    private String id;
    private String object;
    private Long balance;
    private Long created;
    private String currency;

    @JsonProperty("default_source")
    private String defaultSource;

    private Boolean delinquent;
    private String description;
    private String email;
    private String name;
    private String phone;
    private Address address;
    private Map<String, String> metadata;

    @JsonProperty("tax_exempt")
    private String taxExempt;
    // accessors
}

public class Address {
    private String city;
    private String country;
    private String line1;

    @JsonProperty("postal_code")
    private String postalCode;
    // accessors
}

Notes on the Stripe Schema

  • balance and created should be Long — Stripe uses Unix timestamps (10-digit integers, currently fitting in Integer but trending toward Long once timestamps cross 2_147_483_648 in 2038).
  • Money is in the smallest currency unitbalance of 0 means $0.00 USD. Convert to BigDecimal at the application layer.
  • metadata is a free-form map of String → String (Stripe enforces string values). Always model as Map<String, String>, not as a generated class.
  • tax_exempt is an enum stringnone, exempt, reverse. After generation, refine to a Java enum for type safety.

Refined Address as a Record

public record Address(String city, String country, String line1,
                      @JsonProperty("postal_code") String postalCode) {}

Stripe SDK as an Alternative

Stripe ships an official Java SDK that already includes typed POJOs for every API resource. Generate POJOs by hand only if you need to wrap a Stripe webhook payload, decouple from the SDK version, or strip down the model to just the fields you use.

Use Case

Subscription billing integrations, marketplace platforms, and SaaS billing analytics often need a slim, project-specific representation of Stripe objects rather than the full SDK class. Generated POJOs give you exactly the fields you consume.

Try It — JSON to Java

Open full tool