Does anybody know why @[JSON::Field]
was chosen?
JSON standard itself doesn’t seem to define how to call names on the left in JSON object.
I understand that @[JSON::Field]
is short and is most googleable. I’ve tried googling JSON field, JSON property, and JSON attribute and they seem to be in use in this order.
I’m searching GitHub issues and PRs and can’t find where the decision to use @[JSON::Field]
in JSON::Serializable
was made. Other discussed options seem to be at least @[JSON::Attribute]
.
I wonder if @[JSON::Property]
is more coherent with normal Crystal property
than @[JSON::Field]
, e.g.:
@[JSON::Serializable]
class Point
@[JSON::Property]
property x : Int32
@[JSON::Property]
property y : Int32
end
I like @[JSON::Field]
being short, but @[JSON::Property]
seem to be closer to Crystal, and also maybe more universal if formats other that JSON considered (@[YAML::Property]
etc.)