Ruby 2.4.0 リファレンスマニュアル > ライブラリ一覧 > jsonライブラリ > JSON::Generator::GeneratorMethods::Integerモジュール > to_json

instance method JSON::Generator::GeneratorMethods::Integer#to_json

to_json(state_or_hash = nil) -> String[permalink][rdoc]

自身から生成した JSON 形式の文字列を返します。

[PARAM] state_or_hash:
生成する JSON 形式の文字列をカスタマイズするために JSON::State のインスタンスか、 JSON::State.new の引数と同じ Hash を指定します。


require "json"

10.to_json # => "10"