diff --git a/stdlib/json/0/json.rbs b/stdlib/json/0/json.rbs index ca8963b6c..6d242c831 100644 --- a/stdlib/json/0/json.rbs +++ b/stdlib/json/0/json.rbs @@ -2,26 +2,6 @@ interface _ToJson def to_json: (?JSON::State state) -> String end -interface _JsonToWritableIO - def to_io: () -> _JsonWrite -end - -interface _JsonWrite - def write: (String json) -> void - - def flush: () -> void -end - -interface _JsonReadableIO - def to_io: () -> _JsonRead -end - -interface _JsonRead - def read: () -> string -end - -type json_options = Hash[Symbol, untyped] - # # The base exception for JSON errors. # @@ -96,10 +76,6 @@ end class JSON::Pure::Parser end -type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator) -type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser) -type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State) - # # # JavaScript Object Notation (JSON) # @@ -675,6 +651,32 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure: # With custom addition: # (Foo) # module JSON + type options = Hash[Symbol, untyped] + + type generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator) + + type parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser) + + type state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State) + + interface _WritableIO + def to_io: () -> _Write + end + + interface _Write + def write: (String json) -> void + + def flush: () -> void + end + + interface _ReadableIO + def to_io: () -> _Read + end + + interface _Read + def read: () -> string + end + # # Sets or returns the default options for the JSON.dump method. Initially: # opts = JSON.dump_default_options # opts # => {:max_nesting=>false, :allow_nan=>true} # - def self.dump_default_options: () -> json_options + def self.dump_default_options: () -> options # # Sets or returns the default options for the JSON.dump method. Initially: # opts = JSON.dump_default_options # opts # => {:max_nesting=>false, :allow_nan=>true} # - def self.dump_default_options=: (json_options) -> json_options + def self.dump_default_options=: (options) -> options # # Returns the JSON generator module that is used by JSON. # - def self.generator: () -> json_generator + def self.generator: () -> generator - def self.generator=: (json_generator generator) -> void + def self.generator=: (generator generator) -> void # # Sets or returns default options for the JSON.load method. Initially: # opts = JSON.load_default_options # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true} # - def self.load_default_options: () -> json_options + def self.load_default_options: () -> options # # Sets or returns default options for the JSON.load method. Initially: # opts = JSON.load_default_options # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true} # - def self.load_default_options=: (json_options) -> json_options + def self.load_default_options=: (options) -> options # # Returns the JSON parser class that is used by JSON. # - def self.parser: () -> json_parser + def self.parser: () -> parser - def self.parser=: (json_parser parser) -> void + def self.parser=: (parser parser) -> void # # Sets or Returns the JSON generator state class that is used by JSON. # - def self.state: () -> json_state + def self.state: () -> state # # Sets or Returns the JSON generator state class that is used by JSON. # - def self.state=: (json_state) -> json_state + def self.state=: (state) -> state alias self.unparse self.generate alias unparse generate end -JSON::FAST_STATE_PROTOTYPE: json_state +JSON::FAST_STATE_PROTOTYPE: JSON::state JSON::Infinity: Float @@ -1166,9 +1168,9 @@ JSON::MinusInfinity: Float JSON::NaN: Float -JSON::PRETTY_STATE_PROTOTYPE: json_state +JSON::PRETTY_STATE_PROTOTYPE: JSON::state -JSON::SAFE_STATE_PROTOTYPE: json_state +JSON::SAFE_STATE_PROTOTYPE: JSON::state JSON::VERSION: String @@ -1213,8 +1215,8 @@ module Kernel # The *opts* argument is passed through to generate/parse respectively. See # generate and parse for their documentation. # - def JSON: (string source, ?json_options opts) -> untyped - | (_ToJson obj, ?json_options opts) -> String + def JSON: (string source, ?JSON::options opts) -> untyped + | (_ToJson obj, ?JSON::options opts) -> String end %a{annotate:rdoc:skip}