annotation Athena::Serializer::Annotations::Exclude

Overview

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

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

Example

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

  def initialize; end

  property name : String = "Jim"

  @[ASRA::Exclude]
  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.

Defined in:

annotations.cr