Turning a JSON response into model classes
Pick a language, paste the JSON, and the model code comes out as TypeScript interfaces, Python dataclasses or Java records. Nested objects become types of their own, and an array of objects is inferred from every element merged together, so a field that appears in only one element is not lost.
Each language has its own trap. A Python dataclass fails to define at all when a field without a default follows one with it, so optional fields are moved to the end, and keys renamed to snake_case keep the original key in a comment. Java output uses records, and because one file may hold only one public type, only the top-level type is public. TypeScript quotes any key that is not a valid identifier. As of October 2026 the output of all three languages has been checked by compiling and running it.
Nulls, empty arrays and arrays of mixed types carry no type information, so nothing is guessed and each location is reported by path. The supported languages are only the three in the selector, and Go structs are out of scope. No deserialiser configuration or validation code is added.
Frequently Asked Questions
Because only output that was actually generated, compiled and run is offered here. A language not in the list is not produced. For Go structs there is a dedicated tool.
A dataclass raises an error at definition time when a field without a default follows one that has a default, so every Optional field is grouped at the end.
A JSON value can be null and a primitive such as int or long cannot hold null. With boxed types off, deserialising a null fails, so boxed is the default.