Skip to content

annotation Athena::Serializer::Annotations::Expose #

Indicates that a property should be serialized/deserialized when used with :all ASRA::ExclusionPolicy.

Also see, ASRA::IgnoreOnDeserialize and ASRA::IgnoreOnSerialize.

Example#

@[ASRA::ExclusionPolicy(:all)]
class Example
  include ASR::Serializable

  def initialize; end

  @[ASRA::Expose]
  property name : String = "Jim"

  property password : String = "monkey"
end

ASR.serializer.serialize Example.new, :json                                          # => {"name":"Jim"}
ASR.serializer.deserialize Example, %({"name":"Jim","password":"password1!"}), :json # => #<Example:0x7f6eec4b6a60 @name="Jim", @password="monkey">

Warning

On deserialization, the excluded properties must be nilable, or have a default value.