module NASON::ArrayConverter(Converter)

Overview

Converter to be used with NASON::Serializable to serialize the Array(T) elements with the custom converter.

require "nason"

class TimestampArray
  include NASON::Serializable

  @[NASON::Field(converter: NASON::ArrayConverter(Time::EpochConverter))]
  property dates : Array(Time)
end

timestamp = TimestampArray.from_nason(%({"dates":[1459859781,1567628762]}))
timestamp.dates    # => [2016-04-05 12:36:21 UTC, 2019-09-04 20:26:02 UTC]
timestamp.to_nason # => %({"dates":[1459859781,1567628762]})

Defined in:

nason/from_json.cr
nason/to_json.cr

Class Method Summary

Class Method Detail

def self.from_nason(pull : NASON::PullParser) #

[View source]
def self.to_nason(values : Array, builder : NASON::Builder) #

[View source]