るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.080秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:new[x] > モジュール:JSON::Generator::GeneratorMethods::Object[x]

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

検索結果

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