Skip to content

module Athena::Serializer::Serializable #

Adds the necessary methods to a struct/class to allow for (de)serialization of that type.

require "athena-serializer"

record Example, id : Int32, name : String do
  include ASR::Serializable
end

obj = ASR.serializer.deserialize Example, %({"id":1,"name":"George"}), :json
obj                                 # => Example(@id=1, @name="George")
ASR.serializer.serialize obj, :yaml # =>
# ---
# id: 1
# name: George