Generate Delphi classes from JSON
Paste a sample of the JSON your Delphi code receives and this app writes a
unit with a class for each object in it. Each field carries a JSONName attribute
with the exact JSON key, so the classes work with REST.Json's
TJson.JsonToObject and TJson.ObjectToJsonString.
Open the app
How to use it
- JSON : paste an example object, or an array of objects.
- Root class name : the name of the top class, TRoot by default.
- Unit name : used for the unit line and the downloaded file name.
- Delphi style names : first_name and firstName both become First_Name.
Untick it to keep the JSON names.
- Private fields with public properties : untick it for public fields only.
- Copy or Download .pas the result.
How JSON values become Delphi types
- Text becomes string, true and false become Boolean.
- Whole numbers become Integer, or Int64 when they are too big. Numbers with
decimals become Double.
- An object becomes a class. An array becomes TArray, and an array of objects
becomes a TArray of a class named in the singular, so orders gives TOrder.
- All objects in an array are merged, so a key that only some items have is
still included.
- A key that is only ever null becomes string.
- Classes that hold other objects get a destructor that frees them.
- Your JSON stays in your browser. Nothing is uploaded.
More detail is in Embarcadero's
REST.Json.TJson
reference.
Install it as an app
- Chrome on Windows : ⋮ menu → Cast, save and share → Install page as app
- Brave on Windows : ≡ menu → Save and share → Install (app name)
- Chrome on Android : ⋮ menu → Add to Home Screen → Install
- Brave on Android : ⋮ menu → Install and create shortcut
- Safari on iPhone : Share icon → Add to Home Screen
In Chrome and Brave on Windows you can also click the install icon at the right of the address bar.
Written in Delphi with TMS WEB Core.
Back to Apps