module NASON::HashValueConverter(Converter)
Overview
Converter to be used with NASON::Serializable
to serialize the Hash(K, V)
values elements with the custom converter.
require "nason"
class TimestampHash
include NASON::Serializable
@[NASON::Field(converter: NASON::HashValueConverter(Time::EpochConverter))]
property birthdays : Hash(String, Time)
end
timestamp = TimestampHash.from_nason(%({"birthdays":{"foo":1459859781,"bar":1567628762}}))
timestamp.birthdays # => {"foo" => 2016-04-05 12:36:21 UTC, "bar" => 2019-09-04 20:26:02 UTC)}
timestamp.to_nason # => {"birthdays":{"foo":1459859781,"bar":1567628762}}
Defined in:
nason/from_json.crnason/to_json.cr