るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.033秒)
トップページ > クエリ:new[x] > クエリ:to_json[x] > 種類:特異メソッド[x]

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

モジュール

検索結果

JSON.create_id -> String (25.0)

json_create メソッドで使用するクラスを決定するために使用する値を返します。

...def self.json_create(object)
new
(object['id'], object["name"])
end

def as_json(*)
{
JSON.create_id => self.class.name,
"id" => id,
"name" => name,
}
end

def to_json(*)
as_json.to_json
end
end

json = JSON.generate(User.new(1, "tanaka"))
json # => "{\"j...