Why choose the Crystal route instead of Ruby output?
Choose the Crystal route when you want compiled, statically typed model scaffolding with JSON::Serializable support. Choose Ruby when your target stack is Rails or a dynamic Ruby service instead.
Generate Crystal JSON::Serializable classes from sample JSON when you want typed parsing and annotation-ready model scaffolding for Crystal apps.
{
"id": 101,
"name": "Ada Lovelace",
"active": true,
"roles": ["admin", "editor"],
"profile": {
"email": "ada@example.com",
"score": 9.8
}
}
require "json"
class UserModel
include JSON::Serializable
property id : Int32
property name : String
property active : Bool
property roles : Array(String)
end
Choose the Crystal route when you want compiled, statically typed model scaffolding with JSON::Serializable support. Choose Ruby when your target stack is Rails or a dynamic Ruby service instead.
Yes. Nested objects and arrays are expanded into additional Crystal model types so larger payloads stay typed and readable.