Enum values are serialized to their numerical representation. But there’s a recent PR to change that to serializes by name: Serialize Enum to underscored String by caspiano · Pull Request #9905 · crystal-lang/crystal · GitHub
So currently, this is not possible directly - and the mentioned PR does not add an option to configure a name mapping either (that could be added later, though).
It should be rather easy to implement specific for your use case:
# value in JSON: `splith`
# value in JSON: `splitv`
# JSON: `stacked`
# JSON: `tabbed`
in Horizontal then "splith"
in Vertical then "splitv"
in Stacked then "stacked"
in Tabbed then "tabbed"
def to_json(builder : JSON::Builder)
Layout.values.to_json # => "[\"splith\",\"splitv\",\"stacked\",\"tabbed\"]"