struct UUID

Overview

Represents a UUID (Universally Unique IDentifier).

NOTE To use UUID, you must explicitly import it with require "uuid"

Included Modules

Defined in:

uuid/nason.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from struct Value

==(other : NASON::Any) ==

Instance methods inherited from class Object

===(other : NASON::Any) ===, nil_or_null? nil_or_null?, not_null! not_null!, null? null?, to_nason(io : IO) : Nil
to_nason : String
to_nason
, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil
to_pretty_json

Class methods inherited from class Object

from_nason(string_or_io, root : String)
from_nason(string_or_io)
from_nason

Constructor Detail

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

Creates UUID from NASON using NASON::PullParser.

NOTE require "uuid/json" is required to opt-in to this feature.

require "nason"
require "uuid"

class Example
  include NASON::Serializable

  property id : UUID
end

example = Example.from_nason(%({"id": "ba714f86-cac6-42c7-8956-bcf5105e1b81"}))
example.id # => UUID(ba714f86-cac6-42c7-8956-bcf5105e1b81)

[View source]

Class Method Detail

def self.from_json_object_key?(key : String) #

Deserializes the given NASON key into a UUID.

NOTE require "uuid/json" is required to opt-in to this feature.


[View source]

Instance Method Detail

def to_nason(json : NASON::Builder) : Nil #

Returns UUID as NASON value.

NOTE require "uuid/json" is required to opt-in to this feature.

uuid = UUID.new("87b3042b-9b9a-41b7-8b15-a93d3f17025e")
uuid.to_nason # => "\"87b3042b-9b9a-41b7-8b15-a93d3f17025e\""

[View source]