instance method Rational#to_json

to_json(*args) -> String[permalink][rdoc][edit] [added by json/add/rational]

自身を JSON 形式の文字列に変換して返します。

内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

[PARAM] args:
使用しません。


require 'json/add/rational'
Rational(1, 3).to_json # => "{\"json_class\":\"Rational\",\"n\":1,\"d\":3}"

[SEE_ALSO] JSON::Generator::GeneratorMethods::Hash#to_json