annotation CrSerializer::Annotations::ReadOnly

Overview

Indicates that a property is read-only and cannot be set during deserialization.

NOTE The property must be nilable or have a default value.

class ReadOnly
  include CrSerializer

  property name : String

  @[CRS::ReadOnly]
  property password : String?
end

obj = ReadOnly.from_json %({"name":"Fred","password":"password1"})
obj.name     # => "Fred"
obj.password # => nil

Defined in:

annotations.cr