るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.024秒)
トップページ > クエリ:attr[x] > モジュール:JSON::Generator::GeneratorMethods::Object[x]

別のキーワード

  1. module attr
  2. _builtin attr
  3. net/imap attr
  4. rdoc attr_modifiers
  5. etc sc_thread_attr_stackaddr

ライブラリ

検索結果

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (7.0)

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

...JSON::State.new の引数と同じ Hash を
指定します。

//emlist[例][ruby]{
require "json"

class Person
attr
:name, :age

def initialize(name, age)
@name, @age = name, age
end
end

tanaka = Person.new("tanaka", 29)

tanaka.to_json # => "\"#<Perso...