as_json(*args) -> HashRuby 1.9.3 から Ruby 4.1 で削除[permalink][rdoc][edit] [added by json/add/date]-
selfを JSON 形式の文字列に変換する際に使う、中間表現となるハッシュに変換して返します。 Date#to_json が内部で使用しています。ハッシュには、JSON.create_id をキーとしてクラス名が、
'y'に年(Date#year)、'm'に月(Date#month)、'd'に日(Date#day)、'sg'に改暦日 (Date#start)が入ります。- [PARAM]
args: - 無視されます。
require 'json/add/date' hash = Date.new(2024, 1, 2).as_json p hash['json_class'] # => "Date" p hash['y'] # => 2024 p hash['m'] # => 1 p hash['d'] # => 2 p hash['sg'] # => 2299161.0[SEE_ALSO] Date#to_json, Date.json_create
- [PARAM]