Ruby 4.0 リファレンスマニュアル

instance method Regexp#as_json

as_json(*args) -> HashRuby 1.9.3 から Ruby 4.1 で削除[permalink][rdoc][edit] [added by json/add/regexp]

self を JSON 形式の文字列に変換する際に使う、中間表現となるハッシュに変換して返します。 Regexp#to_json が内部で使用しています。

ハッシュには、JSON.create_id をキーとしてクラス名が、'o' にオプションを表す整数(Regexp#options の返り値)が、's' にパターン文字列 (Regexp#source の返り値)が入ります。

[PARAM] args:
無視されます。
require 'json/add/regexp'

hash = /foo/i.as_json
p hash['json_class'] # => "Regexp"
p hash['o']           # => 1
p hash['s']           # => "foo"

[SEE_ALSO] Regexp#to_json, Regexp.json_create