APIdock / Ruby
/
method

as_json

ruby latest stable - Class: Time
as_json(*)
public

Returns a hash, that will be turned into a JSON object and represent this object.

# File ext/json/lib/json/add/time.rb, line 22
 def as_json(*)
 nanoseconds = [ tv_usec * 1000 ]
 respond_to?(:tv_nsec) and nanoseconds << tv_nsec
 nanoseconds = nanoseconds.max
 {
 JSON.create_id => self.class.name,
 's' => tv_sec,
 'n' => nanoseconds,
 }
 end

AltStyle によって変換されたページ (->オリジナル) /