module String::RawConverter

Overview

Converter to be used with NASON::Serializable to read the raw value of a NASON object property as a String.

It can be useful to read ints and floats without losing precision, or to read an object and deserialize it later based on some condition.

require "nason"

class Raw
  include NASON::Serializable

  @[NASON::Field(converter: String::RawConverter)]
  property value : String
end

raw = Raw.from_nason(%({"value": 123456789876543212345678987654321}))
raw.value    # => "123456789876543212345678987654321"
raw.to_nason # => %({"value":123456789876543212345678987654321})

Defined in:

nason/from_json.cr
nason/to_json.cr

Class Method Summary

Class Method Detail

def self.from_nason(value : NASON::PullParser) : String #

[View source]
def self.to_nason(value : String, json : NASON::Builder) : Nil #

[View source]