るりまサーチ

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

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. argf.class gets
  5. argf.class to_a

ライブラリ

検索結果

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (19.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 # => "...