playoffs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.editorconfig +8 -0
  4. data/.github/workflows/ci.yaml +29 -0
  5. data/.gitignore +8 -0
  6. data/.rubocop.yml +34 -0
  7. data/.tool-versions +1 -0
  8. data/.vscode/settings.json +5 -0
  9. data/CHANGELOG.md +3 -0
  10. data/CODE_OF_CONDUCT.md +73 -0
  11. data/Gemfile +5 -0
  12. data/Guardfile +17 -0
  13. data/LICENSE +5 -0
  14. data/README.md +245 -0
  15. data/Rakefile +11 -0
  16. data/bin/_guard-core +27 -0
  17. data/bin/bundle +109 -0
  18. data/bin/bundle-audit +27 -0
  19. data/bin/bundler-audit +27 -0
  20. data/bin/coderay +27 -0
  21. data/bin/console +11 -0
  22. data/bin/guard +27 -0
  23. data/bin/htmldiff +27 -0
  24. data/bin/ldiff +27 -0
  25. data/bin/listen +27 -0
  26. data/bin/playoffs +27 -0
  27. data/bin/pry +27 -0
  28. data/bin/racc +27 -0
  29. data/bin/rake +27 -0
  30. data/bin/rspec +27 -0
  31. data/bin/rubocop +27 -0
  32. data/bin/ruby-parse +27 -0
  33. data/bin/ruby-rewrite +27 -0
  34. data/bin/spoom +27 -0
  35. data/bin/srb +27 -0
  36. data/bin/srb-rbi +27 -0
  37. data/bin/tapioca +27 -0
  38. data/bin/thor +27 -0
  39. data/bin/yard +27 -0
  40. data/bin/yardoc +27 -0
  41. data/bin/yri +27 -0
  42. data/exe/playoffs +7 -0
  43. data/lib/playoffs/basketball.rb +120 -0
  44. data/lib/playoffs/best_of.rb +38 -0
  45. data/lib/playoffs/cli.rb +201 -0
  46. data/lib/playoffs/contestant.rb +8 -0
  47. data/lib/playoffs/round.rb +42 -0
  48. data/lib/playoffs/series.rb +167 -0
  49. data/lib/playoffs/team.rb +7 -0
  50. data/lib/playoffs/tournament/bracketable.rb +93 -0
  51. data/lib/playoffs/tournament/roundable.rb +53 -0
  52. data/lib/playoffs/tournament.rb +61 -0
  53. data/lib/playoffs/version.rb +6 -0
  54. data/lib/playoffs.rb +26 -0
  55. data/playoffs.gemspec +49 -0
  56. data/sorbet/config +4 -0
  57. data/sorbet/rbi/annotations/.gitattributes +1 -0
  58. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  59. data/sorbet/rbi/gems/.gitattributes +1 -0
  60. data/sorbet/rbi/gems/ansi@1.5.0.rbi +688 -0
  61. data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
  62. data/sorbet/rbi/gems/bundler-audit@0.9.1.rbi +309 -0
  63. data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
  64. data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1131 -0
  65. data/sorbet/rbi/gems/docile@1.4.0.rbi +377 -0
  66. data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
  67. data/sorbet/rbi/gems/ffi@1.16.3.rbi +9 -0
  68. data/sorbet/rbi/gems/formatador@1.1.0.rbi +9 -0
  69. data/sorbet/rbi/gems/guard-compat@1.2.1.rbi +67 -0
  70. data/sorbet/rbi/gems/guard-rspec@4.7.3.rbi +563 -0
  71. data/sorbet/rbi/gems/guard@2.18.1.rbi +9 -0
  72. data/sorbet/rbi/gems/json@2.7.2.rbi +1562 -0
  73. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
  74. data/sorbet/rbi/gems/listen@3.9.0.rbi +9 -0
  75. data/sorbet/rbi/gems/lumberjack@1.2.10.rbi +9 -0
  76. data/sorbet/rbi/gems/method_source@1.1.0.rbi +304 -0
  77. data/sorbet/rbi/gems/nenv@0.3.0.rbi +9 -0
  78. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  79. data/sorbet/rbi/gems/notiffany@0.1.3.rbi +9 -0
  80. data/sorbet/rbi/gems/parallel@1.24.0.rbi +280 -0
  81. data/sorbet/rbi/gems/parser@3.3.1.0.rbi +7238 -0
  82. data/sorbet/rbi/gems/primitive@1.0.0.rbi +58 -0
  83. data/sorbet/rbi/gems/prism@0.29.0.rbi +37987 -0
  84. data/sorbet/rbi/gems/pry@0.14.2.rbi +10069 -0
  85. data/sorbet/rbi/gems/racc@1.7.3.rbi +162 -0
  86. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
  87. data/sorbet/rbi/gems/rake@13.2.1.rbi +3028 -0
  88. data/sorbet/rbi/gems/rb-fsevent@0.11.2.rbi +9 -0
  89. data/sorbet/rbi/gems/rb-inotify@0.10.1.rbi +9 -0
  90. data/sorbet/rbi/gems/rbi@0.1.13.rbi +3078 -0
  91. data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
  92. data/sorbet/rbi/gems/rexml@3.2.8.rbi +4794 -0
  93. data/sorbet/rbi/gems/rspec-core@3.13.0.rbi +10874 -0
  94. data/sorbet/rbi/gems/rspec-expectations@3.13.0.rbi +8154 -0
  95. data/sorbet/rbi/gems/rspec-mocks@3.13.1.rbi +5341 -0
  96. data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +1630 -0
  97. data/sorbet/rbi/gems/rspec@3.13.0.rbi +83 -0
  98. data/sorbet/rbi/gems/rubocop-ast@1.31.3.rbi +7159 -0
  99. data/sorbet/rbi/gems/rubocop-capybara@2.20.0.rbi +1208 -0
  100. data/sorbet/rbi/gems/rubocop-factory_bot@2.25.1.rbi +928 -0
  101. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +329 -0
  102. data/sorbet/rbi/gems/rubocop-rspec@2.29.2.rbi +8247 -0
  103. data/sorbet/rbi/gems/rubocop-rspec_rails@2.28.3.rbi +911 -0
  104. data/sorbet/rbi/gems/rubocop-sorbet@0.8.3.rbi +1607 -0
  105. data/sorbet/rbi/gems/rubocop@1.63.5.rbi +57788 -0
  106. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  107. data/sorbet/rbi/gems/shellany@0.0.1.rbi +9 -0
  108. data/sorbet/rbi/gems/simplecov-console@0.9.1.rbi +103 -0
  109. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +217 -0
  110. data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2149 -0
  111. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
  112. data/sorbet/rbi/gems/sorbet-runtime-stub@0.2.0.rbi +8 -0
  113. data/sorbet/rbi/gems/spoom@1.3.2.rbi +4420 -0
  114. data/sorbet/rbi/gems/strscan@3.1.0.rbi +9 -0
  115. data/sorbet/rbi/gems/tapioca@0.14.2.rbi +3539 -0
  116. data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +9 -0
  117. data/sorbet/rbi/gems/thor@1.3.1.rbi +4318 -0
  118. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +66 -0
  119. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
  120. data/sorbet/rbi/gems/yard@0.9.36.rbi +18085 -0
  121. data/sorbet/tapioca/config.yml +13 -0
  122. data/sorbet/tapioca/require.rb +4 -0
  123. metadata +383 -0
@@ -0,0 +1,1562 @@
1
+ # typed: false
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `json` gem.
5
+ # Please instead update this file by running `bin/tapioca gem json`.
6
+
7
+
8
+ # Extends any Class to include _json_creatable?_ method.
9
+ #
10
+ # source://json//lib/json/common.rb#690
11
+ class Class < ::Module
12
+ # Returns true if this class can be used to create an instance
13
+ # from a serialised JSON string. The class has to implement a class
14
+ # method _json_create_ that expects a hash as first parameter. The hash
15
+ # should include the required data.
16
+ #
17
+ # @return [Boolean]
18
+ #
19
+ # source://json//lib/json/common.rb#695
20
+ def json_creatable?; end
21
+ end
22
+
23
+ # = JavaScript \Object Notation (\JSON)
24
+ #
25
+ # \JSON is a lightweight data-interchange format.
26
+ #
27
+ # A \JSON value is one of the following:
28
+ # - Double-quoted text: <tt>"foo"</tt>.
29
+ # - Number: +1+, +1.0+, +2.0e2+.
30
+ # - Boolean: +true+, +false+.
31
+ # - Null: +null+.
32
+ # - \Array: an ordered list of values, enclosed by square brackets:
33
+ # ["foo", 1, 1.0, 2.0e2, true, false, null]
34
+ #
35
+ # - \Object: a collection of name/value pairs, enclosed by curly braces;
36
+ # each name is double-quoted text;
37
+ # the values may be any \JSON values:
38
+ # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
39
+ #
40
+ # A \JSON array or object may contain nested arrays, objects, and scalars
41
+ # to any depth:
42
+ # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
43
+ # [{"foo": 0, "bar": 1}, ["baz", 2]]
44
+ #
45
+ # == Using \Module \JSON
46
+ #
47
+ # To make module \JSON available in your code, begin with:
48
+ # require 'json'
49
+ #
50
+ # All examples here assume that this has been done.
51
+ #
52
+ # === Parsing \JSON
53
+ #
54
+ # You can parse a \String containing \JSON data using
55
+ # either of two methods:
56
+ # - <tt>JSON.parse(source, opts)</tt>
57
+ # - <tt>JSON.parse!(source, opts)</tt>
58
+ #
59
+ # where
60
+ # - +source+ is a Ruby object.
61
+ # - +opts+ is a \Hash object containing options
62
+ # that control both input allowed and output formatting.
63
+ #
64
+ # The difference between the two methods
65
+ # is that JSON.parse! omits some checks
66
+ # and may not be safe for some +source+ data;
67
+ # use it only for data from trusted sources.
68
+ # Use the safer method JSON.parse for less trusted sources.
69
+ #
70
+ # ==== Parsing \JSON Arrays
71
+ #
72
+ # When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:
73
+ # json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
74
+ # ruby = JSON.parse(json)
75
+ # ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
76
+ # ruby.class # => Array
77
+ #
78
+ # The \JSON array may contain nested arrays, objects, and scalars
79
+ # to any depth:
80
+ # json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
81
+ # JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
82
+ #
83
+ # ==== Parsing \JSON \Objects
84
+ #
85
+ # When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:
86
+ # json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
87
+ # ruby = JSON.parse(json)
88
+ # ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
89
+ # ruby.class # => Hash
90
+ #
91
+ # The \JSON object may contain nested arrays, objects, and scalars
92
+ # to any depth:
93
+ # json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
94
+ # JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
95
+ #
96
+ # ==== Parsing \JSON Scalars
97
+ #
98
+ # When the source is a \JSON scalar (not an array or object),
99
+ # JSON.parse returns a Ruby scalar.
100
+ #
101
+ # \String:
102
+ # ruby = JSON.parse('"foo"')
103
+ # ruby # => 'foo'
104
+ # ruby.class # => String
105
+ # \Integer:
106
+ # ruby = JSON.parse('1')
107
+ # ruby # => 1
108
+ # ruby.class # => Integer
109
+ # \Float:
110
+ # ruby = JSON.parse('1.0')
111
+ # ruby # => 1.0
112
+ # ruby.class # => Float
113
+ # ruby = JSON.parse('2.0e2')
114
+ # ruby # => 200
115
+ # ruby.class # => Float
116
+ # Boolean:
117
+ # ruby = JSON.parse('true')
118
+ # ruby # => true
119
+ # ruby.class # => TrueClass
120
+ # ruby = JSON.parse('false')
121
+ # ruby # => false
122
+ # ruby.class # => FalseClass
123
+ # Null:
124
+ # ruby = JSON.parse('null')
125
+ # ruby # => nil
126
+ # ruby.class # => NilClass
127
+ #
128
+ # ==== Parsing Options
129
+ #
130
+ # ====== Input Options
131
+ #
132
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed;
133
+ # defaults to +100+; specify +false+ to disable depth checking.
134
+ #
135
+ # With the default, +false+:
136
+ # source = '[0, [1, [2, [3]]]]'
137
+ # ruby = JSON.parse(source)
138
+ # ruby # => [0, [1, [2, [3]]]]
139
+ # Too deep:
140
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
141
+ # JSON.parse(source, {max_nesting: 1})
142
+ # Bad value:
143
+ # # Raises TypeError (wrong argument type Symbol (expected Fixnum)):
144
+ # JSON.parse(source, {max_nesting: :foo})
145
+ #
146
+ # ---
147
+ #
148
+ # Option +allow_nan+ (boolean) specifies whether to allow
149
+ # NaN, Infinity, and MinusInfinity in +source+;
150
+ # defaults to +false+.
151
+ #
152
+ # With the default, +false+:
153
+ # # Raises JSON::ParserError (225: unexpected token at '[NaN]'):
154
+ # JSON.parse('[NaN]')
155
+ # # Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
156
+ # JSON.parse('[Infinity]')
157
+ # # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
158
+ # JSON.parse('[-Infinity]')
159
+ # Allow:
160
+ # source = '[NaN, Infinity, -Infinity]'
161
+ # ruby = JSON.parse(source, {allow_nan: true})
162
+ # ruby # => [NaN, Infinity, -Infinity]
163
+ #
164
+ # ====== Output Options
165
+ #
166
+ # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
167
+ # should be Symbols;
168
+ # defaults to +false+ (use Strings).
169
+ #
170
+ # With the default, +false+:
171
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
172
+ # ruby = JSON.parse(source)
173
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
174
+ # Use Symbols:
175
+ # ruby = JSON.parse(source, {symbolize_names: true})
176
+ # ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
177
+ #
178
+ # ---
179
+ #
180
+ # Option +object_class+ (\Class) specifies the Ruby class to be used
181
+ # for each \JSON object;
182
+ # defaults to \Hash.
183
+ #
184
+ # With the default, \Hash:
185
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
186
+ # ruby = JSON.parse(source)
187
+ # ruby.class # => Hash
188
+ # Use class \OpenStruct:
189
+ # ruby = JSON.parse(source, {object_class: OpenStruct})
190
+ # ruby # => #<OpenStruct a="foo", b=1.0, c=true, d=false, e=nil>
191
+ #
192
+ # ---
193
+ #
194
+ # Option +array_class+ (\Class) specifies the Ruby class to be used
195
+ # for each \JSON array;
196
+ # defaults to \Array.
197
+ #
198
+ # With the default, \Array:
199
+ # source = '["foo", 1.0, true, false, null]'
200
+ # ruby = JSON.parse(source)
201
+ # ruby.class # => Array
202
+ # Use class \Set:
203
+ # ruby = JSON.parse(source, {array_class: Set})
204
+ # ruby # => #<Set: {"foo", 1.0, true, false, nil}>
205
+ #
206
+ # ---
207
+ #
208
+ # Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing.
209
+ # See {\JSON Additions}[#module-JSON-label-JSON+Additions].
210
+ #
211
+ # === Generating \JSON
212
+ #
213
+ # To generate a Ruby \String containing \JSON data,
214
+ # use method <tt>JSON.generate(source, opts)</tt>, where
215
+ # - +source+ is a Ruby object.
216
+ # - +opts+ is a \Hash object containing options
217
+ # that control both input allowed and output formatting.
218
+ #
219
+ # ==== Generating \JSON from Arrays
220
+ #
221
+ # When the source is a Ruby \Array, JSON.generate returns
222
+ # a \String containing a \JSON array:
223
+ # ruby = [0, 's', :foo]
224
+ # json = JSON.generate(ruby)
225
+ # json # => '[0,"s","foo"]'
226
+ #
227
+ # The Ruby \Array array may contain nested arrays, hashes, and scalars
228
+ # to any depth:
229
+ # ruby = [0, [1, 2], {foo: 3, bar: 4}]
230
+ # json = JSON.generate(ruby)
231
+ # json # => '[0,[1,2],{"foo":3,"bar":4}]'
232
+ #
233
+ # ==== Generating \JSON from Hashes
234
+ #
235
+ # When the source is a Ruby \Hash, JSON.generate returns
236
+ # a \String containing a \JSON object:
237
+ # ruby = {foo: 0, bar: 's', baz: :bat}
238
+ # json = JSON.generate(ruby)
239
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
240
+ #
241
+ # The Ruby \Hash array may contain nested arrays, hashes, and scalars
242
+ # to any depth:
243
+ # ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
244
+ # json = JSON.generate(ruby)
245
+ # json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
246
+ #
247
+ # ==== Generating \JSON from Other Objects
248
+ #
249
+ # When the source is neither an \Array nor a \Hash,
250
+ # the generated \JSON data depends on the class of the source.
251
+ #
252
+ # When the source is a Ruby \Integer or \Float, JSON.generate returns
253
+ # a \String containing a \JSON number:
254
+ # JSON.generate(42) # => '42'
255
+ # JSON.generate(0.42) # => '0.42'
256
+ #
257
+ # When the source is a Ruby \String, JSON.generate returns
258
+ # a \String containing a \JSON string (with double-quotes):
259
+ # JSON.generate('A string') # => '"A string"'
260
+ #
261
+ # When the source is +true+, +false+ or +nil+, JSON.generate returns
262
+ # a \String containing the corresponding \JSON token:
263
+ # JSON.generate(true) # => 'true'
264
+ # JSON.generate(false) # => 'false'
265
+ # JSON.generate(nil) # => 'null'
266
+ #
267
+ # When the source is none of the above, JSON.generate returns
268
+ # a \String containing a \JSON string representation of the source:
269
+ # JSON.generate(:foo) # => '"foo"'
270
+ # JSON.generate(Complex(0, 0)) # => '"0+0i"'
271
+ # JSON.generate(Dir.new('.')) # => '"#<Dir>"'
272
+ #
273
+ # ==== Generating Options
274
+ #
275
+ # ====== Input Options
276
+ #
277
+ # Option +allow_nan+ (boolean) specifies whether
278
+ # +NaN+, +Infinity+, and <tt>-Infinity</tt> may be generated;
279
+ # defaults to +false+.
280
+ #
281
+ # With the default, +false+:
282
+ # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
283
+ # JSON.generate(JSON::NaN)
284
+ # # Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
285
+ # JSON.generate(JSON::Infinity)
286
+ # # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
287
+ # JSON.generate(JSON::MinusInfinity)
288
+ #
289
+ # Allow:
290
+ # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
291
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
292
+ #
293
+ # ---
294
+ #
295
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth
296
+ # in +obj+; defaults to +100+.
297
+ #
298
+ # With the default, +100+:
299
+ # obj = [[[[[[0]]]]]]
300
+ # JSON.generate(obj) # => '[[[[[[0]]]]]]'
301
+ #
302
+ # Too deep:
303
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
304
+ # JSON.generate(obj, max_nesting: 2)
305
+ #
306
+ # ====== Escaping Options
307
+ #
308
+ # Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
309
+ # and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
310
+ # tags.
311
+ #
312
+ # Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
313
+ # should be escaped.
314
+ #
315
+ # ====== Output Options
316
+ #
317
+ # The default formatting options generate the most compact
318
+ # \JSON data, all on one line and with no whitespace.
319
+ #
320
+ # You can use these formatting options to generate
321
+ # \JSON data in a more open format, using whitespace.
322
+ # See also JSON.pretty_generate.
323
+ #
324
+ # - Option +array_nl+ (\String) specifies a string (usually a newline)
325
+ # to be inserted after each \JSON array; defaults to the empty \String, <tt>''</tt>.
326
+ # - Option +object_nl+ (\String) specifies a string (usually a newline)
327
+ # to be inserted after each \JSON object; defaults to the empty \String, <tt>''</tt>.
328
+ # - Option +indent+ (\String) specifies the string (usually spaces) to be
329
+ # used for indentation; defaults to the empty \String, <tt>''</tt>;
330
+ # defaults to the empty \String, <tt>''</tt>;
331
+ # has no effect unless options +array_nl+ or +object_nl+ specify newlines.
332
+ # - Option +space+ (\String) specifies a string (usually a space) to be
333
+ # inserted after the colon in each \JSON object's pair;
334
+ # defaults to the empty \String, <tt>''</tt>.
335
+ # - Option +space_before+ (\String) specifies a string (usually a space) to be
336
+ # inserted before the colon in each \JSON object's pair;
337
+ # defaults to the empty \String, <tt>''</tt>.
338
+ #
339
+ # In this example, +obj+ is used first to generate the shortest
340
+ # \JSON data (no whitespace), then again with all formatting options
341
+ # specified:
342
+ #
343
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
344
+ # json = JSON.generate(obj)
345
+ # puts 'Compact:', json
346
+ # opts = {
347
+ # array_nl: "\n",
348
+ # object_nl: "\n",
349
+ # indent: ' ',
350
+ # space_before: ' ',
351
+ # space: ' '
352
+ # }
353
+ # puts 'Open:', JSON.generate(obj, opts)
354
+ #
355
+ # Output:
356
+ # Compact:
357
+ # {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
358
+ # Open:
359
+ # {
360
+ # "foo" : [
361
+ # "bar",
362
+ # "baz"
363
+ # ],
364
+ # "bat" : {
365
+ # "bam" : 0,
366
+ # "bad" : 1
367
+ # }
368
+ # }
369
+ #
370
+ # == \JSON Additions
371
+ #
372
+ # When you "round trip" a non-\String object from Ruby to \JSON and back,
373
+ # you have a new \String, instead of the object you began with:
374
+ # ruby0 = Range.new(0, 2)
375
+ # json = JSON.generate(ruby0)
376
+ # json # => '0..2"'
377
+ # ruby1 = JSON.parse(json)
378
+ # ruby1 # => '0..2'
379
+ # ruby1.class # => String
380
+ #
381
+ # You can use \JSON _additions_ to preserve the original object.
382
+ # The addition is an extension of a ruby class, so that:
383
+ # - \JSON.generate stores more information in the \JSON string.
384
+ # - \JSON.parse, called with option +create_additions+,
385
+ # uses that information to create a proper Ruby object.
386
+ #
387
+ # This example shows a \Range being generated into \JSON
388
+ # and parsed back into Ruby, both without and with
389
+ # the addition for \Range:
390
+ # ruby = Range.new(0, 2)
391
+ # # This passage does not use the addition for Range.
392
+ # json0 = JSON.generate(ruby)
393
+ # ruby0 = JSON.parse(json0)
394
+ # # This passage uses the addition for Range.
395
+ # require 'json/add/range'
396
+ # json1 = JSON.generate(ruby)
397
+ # ruby1 = JSON.parse(json1, create_additions: true)
398
+ # # Make a nice display.
399
+ # display = <<EOT
400
+ # Generated JSON:
401
+ # Without addition: #{json0} (#{json0.class})
402
+ # With addition: #{json1} (#{json1.class})
403
+ # Parsed JSON:
404
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
405
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
406
+ # EOT
407
+ # puts display
408
+ #
409
+ # This output shows the different results:
410
+ # Generated JSON:
411
+ # Without addition: "0..2" (String)
412
+ # With addition: {"json_class":"Range","a":[0,2,false]} (String)
413
+ # Parsed JSON:
414
+ # Without addition: "0..2" (String)
415
+ # With addition: 0..2 (Range)
416
+ #
417
+ # The \JSON module includes additions for certain classes.
418
+ # You can also craft custom additions.
419
+ # See {Custom \JSON Additions}[#module-JSON-label-Custom+JSON+Additions].
420
+ #
421
+ # === Built-in Additions
422
+ #
423
+ # The \JSON module includes additions for certain classes.
424
+ # To use an addition, +require+ its source:
425
+ # - BigDecimal: <tt>require 'json/add/bigdecimal'</tt>
426
+ # - Complex: <tt>require 'json/add/complex'</tt>
427
+ # - Date: <tt>require 'json/add/date'</tt>
428
+ # - DateTime: <tt>require 'json/add/date_time'</tt>
429
+ # - Exception: <tt>require 'json/add/exception'</tt>
430
+ # - OpenStruct: <tt>require 'json/add/ostruct'</tt>
431
+ # - Range: <tt>require 'json/add/range'</tt>
432
+ # - Rational: <tt>require 'json/add/rational'</tt>
433
+ # - Regexp: <tt>require 'json/add/regexp'</tt>
434
+ # - Set: <tt>require 'json/add/set'</tt>
435
+ # - Struct: <tt>require 'json/add/struct'</tt>
436
+ # - Symbol: <tt>require 'json/add/symbol'</tt>
437
+ # - Time: <tt>require 'json/add/time'</tt>
438
+ #
439
+ # To reduce punctuation clutter, the examples below
440
+ # show the generated \JSON via +puts+, rather than the usual +inspect+,
441
+ #
442
+ # \BigDecimal:
443
+ # require 'json/add/bigdecimal'
444
+ # ruby0 = BigDecimal(0) # 0.0
445
+ # json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"}
446
+ # ruby1 = JSON.parse(json, create_additions: true) # 0.0
447
+ # ruby1.class # => BigDecimal
448
+ #
449
+ # \Complex:
450
+ # require 'json/add/complex'
451
+ # ruby0 = Complex(1+0i) # 1+0i
452
+ # json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0}
453
+ # ruby1 = JSON.parse(json, create_additions: true) # 1+0i
454
+ # ruby1.class # Complex
455
+ #
456
+ # \Date:
457
+ # require 'json/add/date'
458
+ # ruby0 = Date.today # 2020-05-02
459
+ # json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0}
460
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02
461
+ # ruby1.class # Date
462
+ #
463
+ # \DateTime:
464
+ # require 'json/add/date_time'
465
+ # ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00
466
+ # json = JSON.generate(ruby0) # {"json_class":"DateTime","y":2020,"m":5,"d":2,"H":10,"M":38,"S":13,"of":"-5/24","sg":2299161.0}
467
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00
468
+ # ruby1.class # DateTime
469
+ #
470
+ # \Exception (and its subclasses including \RuntimeError):
471
+ # require 'json/add/exception'
472
+ # ruby0 = Exception.new('A message') # A message
473
+ # json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null}
474
+ # ruby1 = JSON.parse(json, create_additions: true) # A message
475
+ # ruby1.class # Exception
476
+ # ruby0 = RuntimeError.new('Another message') # Another message
477
+ # json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null}
478
+ # ruby1 = JSON.parse(json, create_additions: true) # Another message
479
+ # ruby1.class # RuntimeError
480
+ #
481
+ # \OpenStruct:
482
+ # require 'json/add/ostruct'
483
+ # ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # #<OpenStruct name="Matz", language="Ruby">
484
+ # json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}}
485
+ # ruby1 = JSON.parse(json, create_additions: true) # #<OpenStruct name="Matz", language="Ruby">
486
+ # ruby1.class # OpenStruct
487
+ #
488
+ # \Range:
489
+ # require 'json/add/range'
490
+ # ruby0 = Range.new(0, 2) # 0..2
491
+ # json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]}
492
+ # ruby1 = JSON.parse(json, create_additions: true) # 0..2
493
+ # ruby1.class # Range
494
+ #
495
+ # \Rational:
496
+ # require 'json/add/rational'
497
+ # ruby0 = Rational(1, 3) # 1/3
498
+ # json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3}
499
+ # ruby1 = JSON.parse(json, create_additions: true) # 1/3
500
+ # ruby1.class # Rational
501
+ #
502
+ # \Regexp:
503
+ # require 'json/add/regexp'
504
+ # ruby0 = Regexp.new('foo') # (?-mix:foo)
505
+ # json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"}
506
+ # ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo)
507
+ # ruby1.class # Regexp
508
+ #
509
+ # \Set:
510
+ # require 'json/add/set'
511
+ # ruby0 = Set.new([0, 1, 2]) # #<Set: {0, 1, 2}>
512
+ # json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]}
513
+ # ruby1 = JSON.parse(json, create_additions: true) # #<Set: {0, 1, 2}>
514
+ # ruby1.class # Set
515
+ #
516
+ # \Struct:
517
+ # require 'json/add/struct'
518
+ # Customer = Struct.new(:name, :address) # Customer
519
+ # ruby0 = Customer.new("Dave", "123 Main") # #<struct Customer name="Dave", address="123 Main">
520
+ # json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]}
521
+ # ruby1 = JSON.parse(json, create_additions: true) # #<struct Customer name="Dave", address="123 Main">
522
+ # ruby1.class # Customer
523
+ #
524
+ # \Symbol:
525
+ # require 'json/add/symbol'
526
+ # ruby0 = :foo # foo
527
+ # json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"}
528
+ # ruby1 = JSON.parse(json, create_additions: true) # foo
529
+ # ruby1.class # Symbol
530
+ #
531
+ # \Time:
532
+ # require 'json/add/time'
533
+ # ruby0 = Time.now # 2020-05-02 11:28:26 -0500
534
+ # json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000}
535
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500
536
+ # ruby1.class # Time
537
+ #
538
+ #
539
+ # === Custom \JSON Additions
540
+ #
541
+ # In addition to the \JSON additions provided,
542
+ # you can craft \JSON additions of your own,
543
+ # either for Ruby built-in classes or for user-defined classes.
544
+ #
545
+ # Here's a user-defined class +Foo+:
546
+ # class Foo
547
+ # attr_accessor :bar, :baz
548
+ # def initialize(bar, baz)
549
+ # self.bar = bar
550
+ # self.baz = baz
551
+ # end
552
+ # end
553
+ #
554
+ # Here's the \JSON addition for it:
555
+ # # Extend class Foo with JSON addition.
556
+ # class Foo
557
+ # # Serialize Foo object with its class name and arguments
558
+ # def to_json(*args)
559
+ # {
560
+ # JSON.create_id => self.class.name,
561
+ # 'a' => [ bar, baz ]
562
+ # }.to_json(*args)
563
+ # end
564
+ # # Deserialize JSON string by constructing new Foo object with arguments.
565
+ # def self.json_create(object)
566
+ # new(*object['a'])
567
+ # end
568
+ # end
569
+ #
570
+ # Demonstration:
571
+ # require 'json'
572
+ # # This Foo object has no custom addition.
573
+ # foo0 = Foo.new(0, 1)
574
+ # json0 = JSON.generate(foo0)
575
+ # obj0 = JSON.parse(json0)
576
+ # # Lood the custom addition.
577
+ # require_relative 'foo_addition'
578
+ # # This foo has the custom addition.
579
+ # foo1 = Foo.new(0, 1)
580
+ # json1 = JSON.generate(foo1)
581
+ # obj1 = JSON.parse(json1, create_additions: true)
582
+ # # Make a nice display.
583
+ # display = <<EOT
584
+ # Generated JSON:
585
+ # Without custom addition: #{json0} (#{json0.class})
586
+ # With custom addition: #{json1} (#{json1.class})
587
+ # Parsed JSON:
588
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
589
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
590
+ # EOT
591
+ # puts display
592
+ #
593
+ # Output:
594
+ #
595
+ # Generated JSON:
596
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
597
+ # With custom addition: {"json_class":"Foo","a":[0,1]} (String)
598
+ # Parsed JSON:
599
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
600
+ # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
601
+ #
602
+ # source://json//lib/json/version.rb#2
603
+ module JSON
604
+ private
605
+
606
+ # :call-seq:
607
+ # JSON.dump(obj, io = nil, limit = nil)
608
+ #
609
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
610
+ #
611
+ # The default options can be changed via method JSON.dump_default_options.
612
+ #
613
+ # - Argument +io+, if given, should respond to method +write+;
614
+ # the \JSON \String is written to +io+, and +io+ is returned.
615
+ # If +io+ is not given, the \JSON \String is returned.
616
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
617
+ #
618
+ # ---
619
+ #
620
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
621
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
622
+ # json = JSON.dump(obj)
623
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
624
+ #
625
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
626
+ # path = 't.json'
627
+ # File.open(path, 'w') do |file|
628
+ # JSON.dump(obj, file)
629
+ # end # => #<File:t.json (closed)>
630
+ # puts File.read(path)
631
+ # Output:
632
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
633
+ #
634
+ # source://json//lib/json/common.rb#615
635
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
636
+
637
+ # :call-seq:
638
+ # JSON.fast_generate(obj, opts) -> new_string
639
+ #
640
+ # Arguments +obj+ and +opts+ here are the same as
641
+ # arguments +obj+ and +opts+ in JSON.generate.
642
+ #
643
+ # By default, generates \JSON data without checking
644
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
645
+ #
646
+ # Raises an exception if +obj+ contains circular references:
647
+ # a = []; b = []; a.push(b); b.push(a)
648
+ # # Raises SystemStackError (stack level too deep):
649
+ # JSON.fast_generate(a)
650
+ #
651
+ # source://json//lib/json/common.rb#329
652
+ def fast_generate(obj, opts = T.unsafe(nil)); end
653
+
654
+ # :stopdoc:
655
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
656
+ #
657
+ # source://json//lib/json/common.rb#329
658
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
659
+
660
+ # :call-seq:
661
+ # JSON.generate(obj, opts = nil) -> new_string
662
+ #
663
+ # Returns a \String containing the generated \JSON data.
664
+ #
665
+ # See also JSON.fast_generate, JSON.pretty_generate.
666
+ #
667
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
668
+ #
669
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
670
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
671
+ #
672
+ # ---
673
+ #
674
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
675
+ # obj = ["foo", 1.0, true, false, nil]
676
+ # json = JSON.generate(obj)
677
+ # json # => '["foo",1.0,true,false,null]'
678
+ #
679
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
680
+ # obj = {foo: 0, bar: 's', baz: :bat}
681
+ # json = JSON.generate(obj)
682
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
683
+ #
684
+ # For examples of generating from other Ruby objects, see
685
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
686
+ #
687
+ # ---
688
+ #
689
+ # Raises an exception if any formatting option is not a \String.
690
+ #
691
+ # Raises an exception if +obj+ contains circular references:
692
+ # a = []; b = []; a.push(b); b.push(a)
693
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
694
+ # JSON.generate(a)
695
+ #
696
+ # source://json//lib/json/common.rb#300
697
+ def generate(obj, opts = T.unsafe(nil)); end
698
+
699
+ # :call-seq:
700
+ # JSON.load(source, proc = nil, options = {}) -> object
701
+ #
702
+ # Returns the Ruby objects created by parsing the given +source+.
703
+ #
704
+ # - Argument +source+ must be, or be convertible to, a \String:
705
+ # - If +source+ responds to instance method +to_str+,
706
+ # <tt>source.to_str</tt> becomes the source.
707
+ # - If +source+ responds to instance method +to_io+,
708
+ # <tt>source.to_io.read</tt> becomes the source.
709
+ # - If +source+ responds to instance method +read+,
710
+ # <tt>source.read</tt> becomes the source.
711
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
712
+ # - Option +allow_blank+ specifies a truthy value.
713
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
714
+ # - Otherwise, +source+ remains the source.
715
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
716
+ # It will be called recursively with each result (depth-first order).
717
+ # See details below.
718
+ # BEWARE: This method is meant to serialise data from trusted user input,
719
+ # like from your own database server or clients under your control, it could
720
+ # be dangerous to allow untrusted users to pass JSON sources into it.
721
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
722
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
723
+ # The default options can be changed via method JSON.load_default_options=.
724
+ #
725
+ # ---
726
+ #
727
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
728
+ # <tt>parse(source, opts)</tt>; see #parse.
729
+ #
730
+ # Source for following examples:
731
+ # source = <<-EOT
732
+ # {
733
+ # "name": "Dave",
734
+ # "age" :40,
735
+ # "hats": [
736
+ # "Cattleman's",
737
+ # "Panama",
738
+ # "Tophat"
739
+ # ]
740
+ # }
741
+ # EOT
742
+ #
743
+ # Load a \String:
744
+ # ruby = JSON.load(source)
745
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
746
+ #
747
+ # Load an \IO object:
748
+ # require 'stringio'
749
+ # object = JSON.load(StringIO.new(source))
750
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
751
+ #
752
+ # Load a \File object:
753
+ # path = 't.json'
754
+ # File.write(path, source)
755
+ # File.open(path) do |file|
756
+ # JSON.load(file)
757
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
758
+ #
759
+ # ---
760
+ #
761
+ # When +proc+ is given:
762
+ # - Modifies +source+ as above.
763
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
764
+ # - Recursively calls <tt>proc(result)</tt>.
765
+ # - Returns the final result.
766
+ #
767
+ # Example:
768
+ # require 'json'
769
+ #
770
+ # # Some classes for the example.
771
+ # class Base
772
+ # def initialize(attributes)
773
+ # @attributes = attributes
774
+ # end
775
+ # end
776
+ # class User < Base; end
777
+ # class Account < Base; end
778
+ # class Admin < Base; end
779
+ # # The JSON source.
780
+ # json = <<-EOF
781
+ # {
782
+ # "users": [
783
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
784
+ # {"type": "User", "username": "john", "email": "john@example.com"}
785
+ # ],
786
+ # "accounts": [
787
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
788
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
789
+ # ],
790
+ # "admins": {"type": "Admin", "password": "0wn3d"}
791
+ # }
792
+ # EOF
793
+ # # Deserializer method.
794
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
795
+ # type = obj.is_a?(Hash) && obj["type"]
796
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
797
+ # end
798
+ # # Call to JSON.load
799
+ # ruby = JSON.load(json, proc {|obj|
800
+ # case obj
801
+ # when Hash
802
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
803
+ # when Array
804
+ # obj.map! {|v| deserialize_obj v }
805
+ # end
806
+ # })
807
+ # pp ruby
808
+ # Output:
809
+ # {"users"=>
810
+ # [#<User:0x00000000064c4c98
811
+ # @attributes=
812
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
813
+ # #<User:0x00000000064c4bd0
814
+ # @attributes=
815
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
816
+ # "accounts"=>
817
+ # [{"account"=>
818
+ # #<Account:0x00000000064c4928
819
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
820
+ # {"account"=>
821
+ # #<Account:0x00000000064c4680
822
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
823
+ # "admins"=>
824
+ # #<Admin:0x00000000064c41f8
825
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
826
+ #
827
+ # source://json//lib/json/common.rb#541
828
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
829
+
830
+ # :call-seq:
831
+ # JSON.load_file(path, opts={}) -> object
832
+ #
833
+ # Calls:
834
+ # parse(File.read(path), opts)
835
+ #
836
+ # See method #parse.
837
+ #
838
+ # source://json//lib/json/common.rb#249
839
+ def load_file(filespec, opts = T.unsafe(nil)); end
840
+
841
+ # :call-seq:
842
+ # JSON.load_file!(path, opts = {})
843
+ #
844
+ # Calls:
845
+ # JSON.parse!(File.read(path, opts))
846
+ #
847
+ # See method #parse!
848
+ #
849
+ # source://json//lib/json/common.rb#260
850
+ def load_file!(filespec, opts = T.unsafe(nil)); end
851
+
852
+ # source://json//lib/json/common.rb#643
853
+ def merge_dump_options(opts, strict: T.unsafe(nil)); end
854
+
855
+ # :call-seq:
856
+ # JSON.parse(source, opts) -> object
857
+ #
858
+ # Returns the Ruby objects created by parsing the given +source+.
859
+ #
860
+ # Argument +source+ contains the \String to be parsed.
861
+ #
862
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
863
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
864
+ #
865
+ # ---
866
+ #
867
+ # When +source+ is a \JSON array, returns a Ruby \Array:
868
+ # source = '["foo", 1.0, true, false, null]'
869
+ # ruby = JSON.parse(source)
870
+ # ruby # => ["foo", 1.0, true, false, nil]
871
+ # ruby.class # => Array
872
+ #
873
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
874
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
875
+ # ruby = JSON.parse(source)
876
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
877
+ # ruby.class # => Hash
878
+ #
879
+ # For examples of parsing for all \JSON data types, see
880
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
881
+ #
882
+ # Parses nested JSON objects:
883
+ # source = <<-EOT
884
+ # {
885
+ # "name": "Dave",
886
+ # "age" :40,
887
+ # "hats": [
888
+ # "Cattleman's",
889
+ # "Panama",
890
+ # "Tophat"
891
+ # ]
892
+ # }
893
+ # EOT
894
+ # ruby = JSON.parse(source)
895
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
896
+ #
897
+ # ---
898
+ #
899
+ # Raises an exception if +source+ is not valid JSON:
900
+ # # Raises JSON::ParserError (783: unexpected token at ''):
901
+ # JSON.parse('')
902
+ #
903
+ # source://json//lib/json/common.rb#219
904
+ def parse(source, opts = T.unsafe(nil)); end
905
+
906
+ # :call-seq:
907
+ # JSON.parse!(source, opts) -> object
908
+ #
909
+ # Calls
910
+ # parse(source, opts)
911
+ # with +source+ and possibly modified +opts+.
912
+ #
913
+ # Differences from JSON.parse:
914
+ # - Option +max_nesting+, if not provided, defaults to +false+,
915
+ # which disables checking for nesting depth.
916
+ # - Option +allow_nan+, if not provided, defaults to +true+.
917
+ #
918
+ # source://json//lib/json/common.rb#234
919
+ def parse!(source, opts = T.unsafe(nil)); end
920
+
921
+ # :call-seq:
922
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
923
+ #
924
+ # Arguments +obj+ and +opts+ here are the same as
925
+ # arguments +obj+ and +opts+ in JSON.generate.
926
+ #
927
+ # Default options are:
928
+ # {
929
+ # indent: ' ', # Two spaces
930
+ # space: ' ', # One space
931
+ # array_nl: "\n", # Newline
932
+ # object_nl: "\n" # Newline
933
+ # }
934
+ #
935
+ # Example:
936
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
937
+ # json = JSON.pretty_generate(obj)
938
+ # puts json
939
+ # Output:
940
+ # {
941
+ # "foo": [
942
+ # "bar",
943
+ # "baz"
944
+ # ],
945
+ # "bat": {
946
+ # "bam": 0,
947
+ # "bad": 1
948
+ # }
949
+ # }
950
+ #
951
+ # source://json//lib/json/common.rb#374
952
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
953
+
954
+ # :stopdoc:
955
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
956
+ #
957
+ # source://json//lib/json/common.rb#374
958
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
959
+
960
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
961
+ #
962
+ # source://json//lib/json/common.rb#559
963
+ def recurse_proc(result, &proc); end
964
+
965
+ # source://json//lib/json/common.rb#541
966
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
967
+
968
+ # :stopdoc:
969
+ # I want to deprecate these later, so I'll first be silent about them, and
970
+ # later delete them.
971
+ #
972
+ # source://json//lib/json/common.rb#300
973
+ def unparse(obj, opts = T.unsafe(nil)); end
974
+
975
+ class << self
976
+ # :call-seq:
977
+ # JSON[object] -> new_array or new_string
978
+ #
979
+ # If +object+ is a \String,
980
+ # calls JSON.parse with +object+ and +opts+ (see method #parse):
981
+ # json = '[0, 1, null]'
982
+ # JSON[json]# => [0, 1, nil]
983
+ #
984
+ # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
985
+ # ruby = [0, 1, nil]
986
+ # JSON[ruby] # => '[0,1,null]'
987
+ #
988
+ # source://json//lib/json/common.rb#22
989
+ def [](object, opts = T.unsafe(nil)); end
990
+
991
+ # source://json//lib/json/common.rb#85
992
+ def create_fast_state; end
993
+
994
+ # Returns the current create identifier.
995
+ # See also JSON.create_id=.
996
+ #
997
+ # source://json//lib/json/common.rb#130
998
+ def create_id; end
999
+
1000
+ # Sets create identifier, which is used to decide if the _json_create_
1001
+ # hook of a class should be called; initial value is +json_class+:
1002
+ # JSON.create_id # => 'json_class'
1003
+ #
1004
+ # source://json//lib/json/common.rb#124
1005
+ def create_id=(new_value); end
1006
+
1007
+ # source://json//lib/json/common.rb#95
1008
+ def create_pretty_state; end
1009
+
1010
+ # Return the constant located at _path_. The format of _path_ has to be
1011
+ # either ::A::B::C or A::B::C. In any case, A has to be located at the top
1012
+ # level (absolute namespace path?). If there doesn't exist a constant at
1013
+ # the given path, an ArgumentError is raised.
1014
+ #
1015
+ # source://json//lib/json/common.rb#46
1016
+ def deep_const_get(path); end
1017
+
1018
+ # :call-seq:
1019
+ # JSON.dump(obj, io = nil, limit = nil)
1020
+ #
1021
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
1022
+ #
1023
+ # The default options can be changed via method JSON.dump_default_options.
1024
+ #
1025
+ # - Argument +io+, if given, should respond to method +write+;
1026
+ # the \JSON \String is written to +io+, and +io+ is returned.
1027
+ # If +io+ is not given, the \JSON \String is returned.
1028
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
1029
+ #
1030
+ # ---
1031
+ #
1032
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
1033
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
1034
+ # json = JSON.dump(obj)
1035
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
1036
+ #
1037
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
1038
+ # path = 't.json'
1039
+ # File.open(path, 'w') do |file|
1040
+ # JSON.dump(obj, file)
1041
+ # end # => #<File:t.json (closed)>
1042
+ # puts File.read(path)
1043
+ # Output:
1044
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1045
+ #
1046
+ # source://json//lib/json/common.rb#615
1047
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1048
+
1049
+ # Sets or returns the default options for the JSON.dump method.
1050
+ # Initially:
1051
+ # opts = JSON.dump_default_options
1052
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1053
+ #
1054
+ # source://json//lib/json/common.rb#580
1055
+ def dump_default_options; end
1056
+
1057
+ # Sets or returns the default options for the JSON.dump method.
1058
+ # Initially:
1059
+ # opts = JSON.dump_default_options
1060
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1061
+ #
1062
+ # source://json//lib/json/common.rb#580
1063
+ def dump_default_options=(_arg0); end
1064
+
1065
+ # :call-seq:
1066
+ # JSON.fast_generate(obj, opts) -> new_string
1067
+ #
1068
+ # Arguments +obj+ and +opts+ here are the same as
1069
+ # arguments +obj+ and +opts+ in JSON.generate.
1070
+ #
1071
+ # By default, generates \JSON data without checking
1072
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
1073
+ #
1074
+ # Raises an exception if +obj+ contains circular references:
1075
+ # a = []; b = []; a.push(b); b.push(a)
1076
+ # # Raises SystemStackError (stack level too deep):
1077
+ # JSON.fast_generate(a)
1078
+ #
1079
+ # source://json//lib/json/common.rb#329
1080
+ def fast_generate(obj, opts = T.unsafe(nil)); end
1081
+
1082
+ # :stopdoc:
1083
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1084
+ #
1085
+ # source://json//lib/json/common.rb#329
1086
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
1087
+
1088
+ # :call-seq:
1089
+ # JSON.generate(obj, opts = nil) -> new_string
1090
+ #
1091
+ # Returns a \String containing the generated \JSON data.
1092
+ #
1093
+ # See also JSON.fast_generate, JSON.pretty_generate.
1094
+ #
1095
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
1096
+ #
1097
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1098
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
1099
+ #
1100
+ # ---
1101
+ #
1102
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
1103
+ # obj = ["foo", 1.0, true, false, nil]
1104
+ # json = JSON.generate(obj)
1105
+ # json # => '["foo",1.0,true,false,null]'
1106
+ #
1107
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
1108
+ # obj = {foo: 0, bar: 's', baz: :bat}
1109
+ # json = JSON.generate(obj)
1110
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
1111
+ #
1112
+ # For examples of generating from other Ruby objects, see
1113
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
1114
+ #
1115
+ # ---
1116
+ #
1117
+ # Raises an exception if any formatting option is not a \String.
1118
+ #
1119
+ # Raises an exception if +obj+ contains circular references:
1120
+ # a = []; b = []; a.push(b); b.push(a)
1121
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
1122
+ # JSON.generate(a)
1123
+ #
1124
+ # source://json//lib/json/common.rb#300
1125
+ def generate(obj, opts = T.unsafe(nil)); end
1126
+
1127
+ # Returns the JSON generator module that is used by JSON. This is
1128
+ # either JSON::Ext::Generator or JSON::Pure::Generator:
1129
+ # JSON.generator # => JSON::Ext::Generator
1130
+ #
1131
+ # source://json//lib/json/common.rb#107
1132
+ def generator; end
1133
+
1134
+ # Set the module _generator_ to be used by JSON.
1135
+ #
1136
+ # source://json//lib/json/common.rb#62
1137
+ def generator=(generator); end
1138
+
1139
+ # Encodes string using String.encode.
1140
+ #
1141
+ # source://json//lib/json/common.rb#639
1142
+ def iconv(to, from, string); end
1143
+
1144
+ # :call-seq:
1145
+ # JSON.load(source, proc = nil, options = {}) -> object
1146
+ #
1147
+ # Returns the Ruby objects created by parsing the given +source+.
1148
+ #
1149
+ # - Argument +source+ must be, or be convertible to, a \String:
1150
+ # - If +source+ responds to instance method +to_str+,
1151
+ # <tt>source.to_str</tt> becomes the source.
1152
+ # - If +source+ responds to instance method +to_io+,
1153
+ # <tt>source.to_io.read</tt> becomes the source.
1154
+ # - If +source+ responds to instance method +read+,
1155
+ # <tt>source.read</tt> becomes the source.
1156
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1157
+ # - Option +allow_blank+ specifies a truthy value.
1158
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1159
+ # - Otherwise, +source+ remains the source.
1160
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1161
+ # It will be called recursively with each result (depth-first order).
1162
+ # See details below.
1163
+ # BEWARE: This method is meant to serialise data from trusted user input,
1164
+ # like from your own database server or clients under your control, it could
1165
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1166
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1167
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1168
+ # The default options can be changed via method JSON.load_default_options=.
1169
+ #
1170
+ # ---
1171
+ #
1172
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1173
+ # <tt>parse(source, opts)</tt>; see #parse.
1174
+ #
1175
+ # Source for following examples:
1176
+ # source = <<-EOT
1177
+ # {
1178
+ # "name": "Dave",
1179
+ # "age" :40,
1180
+ # "hats": [
1181
+ # "Cattleman's",
1182
+ # "Panama",
1183
+ # "Tophat"
1184
+ # ]
1185
+ # }
1186
+ # EOT
1187
+ #
1188
+ # Load a \String:
1189
+ # ruby = JSON.load(source)
1190
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1191
+ #
1192
+ # Load an \IO object:
1193
+ # require 'stringio'
1194
+ # object = JSON.load(StringIO.new(source))
1195
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1196
+ #
1197
+ # Load a \File object:
1198
+ # path = 't.json'
1199
+ # File.write(path, source)
1200
+ # File.open(path) do |file|
1201
+ # JSON.load(file)
1202
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1203
+ #
1204
+ # ---
1205
+ #
1206
+ # When +proc+ is given:
1207
+ # - Modifies +source+ as above.
1208
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1209
+ # - Recursively calls <tt>proc(result)</tt>.
1210
+ # - Returns the final result.
1211
+ #
1212
+ # Example:
1213
+ # require 'json'
1214
+ #
1215
+ # # Some classes for the example.
1216
+ # class Base
1217
+ # def initialize(attributes)
1218
+ # @attributes = attributes
1219
+ # end
1220
+ # end
1221
+ # class User < Base; end
1222
+ # class Account < Base; end
1223
+ # class Admin < Base; end
1224
+ # # The JSON source.
1225
+ # json = <<-EOF
1226
+ # {
1227
+ # "users": [
1228
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1229
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1230
+ # ],
1231
+ # "accounts": [
1232
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1233
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1234
+ # ],
1235
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1236
+ # }
1237
+ # EOF
1238
+ # # Deserializer method.
1239
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1240
+ # type = obj.is_a?(Hash) && obj["type"]
1241
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1242
+ # end
1243
+ # # Call to JSON.load
1244
+ # ruby = JSON.load(json, proc {|obj|
1245
+ # case obj
1246
+ # when Hash
1247
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1248
+ # when Array
1249
+ # obj.map! {|v| deserialize_obj v }
1250
+ # end
1251
+ # })
1252
+ # pp ruby
1253
+ # Output:
1254
+ # {"users"=>
1255
+ # [#<User:0x00000000064c4c98
1256
+ # @attributes=
1257
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1258
+ # #<User:0x00000000064c4bd0
1259
+ # @attributes=
1260
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1261
+ # "accounts"=>
1262
+ # [{"account"=>
1263
+ # #<Account:0x00000000064c4928
1264
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1265
+ # {"account"=>
1266
+ # #<Account:0x00000000064c4680
1267
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1268
+ # "admins"=>
1269
+ # #<Admin:0x00000000064c41f8
1270
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1271
+ #
1272
+ # source://json//lib/json/common.rb#541
1273
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1274
+
1275
+ # Sets or returns default options for the JSON.load method.
1276
+ # Initially:
1277
+ # opts = JSON.load_default_options
1278
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1279
+ #
1280
+ # source://json//lib/json/common.rb#404
1281
+ def load_default_options; end
1282
+
1283
+ # Sets or returns default options for the JSON.load method.
1284
+ # Initially:
1285
+ # opts = JSON.load_default_options
1286
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1287
+ #
1288
+ # source://json//lib/json/common.rb#404
1289
+ def load_default_options=(_arg0); end
1290
+
1291
+ # :call-seq:
1292
+ # JSON.load_file(path, opts={}) -> object
1293
+ #
1294
+ # Calls:
1295
+ # parse(File.read(path), opts)
1296
+ #
1297
+ # See method #parse.
1298
+ #
1299
+ # source://json//lib/json/common.rb#249
1300
+ def load_file(filespec, opts = T.unsafe(nil)); end
1301
+
1302
+ # :call-seq:
1303
+ # JSON.load_file!(path, opts = {})
1304
+ #
1305
+ # Calls:
1306
+ # JSON.parse!(File.read(path, opts))
1307
+ #
1308
+ # See method #parse!
1309
+ #
1310
+ # source://json//lib/json/common.rb#260
1311
+ def load_file!(filespec, opts = T.unsafe(nil)); end
1312
+
1313
+ # :call-seq:
1314
+ # JSON.parse(source, opts) -> object
1315
+ #
1316
+ # Returns the Ruby objects created by parsing the given +source+.
1317
+ #
1318
+ # Argument +source+ contains the \String to be parsed.
1319
+ #
1320
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
1321
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1322
+ #
1323
+ # ---
1324
+ #
1325
+ # When +source+ is a \JSON array, returns a Ruby \Array:
1326
+ # source = '["foo", 1.0, true, false, null]'
1327
+ # ruby = JSON.parse(source)
1328
+ # ruby # => ["foo", 1.0, true, false, nil]
1329
+ # ruby.class # => Array
1330
+ #
1331
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
1332
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
1333
+ # ruby = JSON.parse(source)
1334
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
1335
+ # ruby.class # => Hash
1336
+ #
1337
+ # For examples of parsing for all \JSON data types, see
1338
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1339
+ #
1340
+ # Parses nested JSON objects:
1341
+ # source = <<-EOT
1342
+ # {
1343
+ # "name": "Dave",
1344
+ # "age" :40,
1345
+ # "hats": [
1346
+ # "Cattleman's",
1347
+ # "Panama",
1348
+ # "Tophat"
1349
+ # ]
1350
+ # }
1351
+ # EOT
1352
+ # ruby = JSON.parse(source)
1353
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1354
+ #
1355
+ # ---
1356
+ #
1357
+ # Raises an exception if +source+ is not valid JSON:
1358
+ # # Raises JSON::ParserError (783: unexpected token at ''):
1359
+ # JSON.parse('')
1360
+ #
1361
+ # source://json//lib/json/common.rb#219
1362
+ def parse(source, opts = T.unsafe(nil)); end
1363
+
1364
+ # :call-seq:
1365
+ # JSON.parse!(source, opts) -> object
1366
+ #
1367
+ # Calls
1368
+ # parse(source, opts)
1369
+ # with +source+ and possibly modified +opts+.
1370
+ #
1371
+ # Differences from JSON.parse:
1372
+ # - Option +max_nesting+, if not provided, defaults to +false+,
1373
+ # which disables checking for nesting depth.
1374
+ # - Option +allow_nan+, if not provided, defaults to +true+.
1375
+ #
1376
+ # source://json//lib/json/common.rb#234
1377
+ def parse!(source, opts = T.unsafe(nil)); end
1378
+
1379
+ # Returns the JSON parser class that is used by JSON. This is either
1380
+ # JSON::Ext::Parser or JSON::Pure::Parser:
1381
+ # JSON.parser # => JSON::Ext::Parser
1382
+ #
1383
+ # source://json//lib/json/common.rb#33
1384
+ def parser; end
1385
+
1386
+ # Set the JSON parser class _parser_ to be used by JSON.
1387
+ #
1388
+ # source://json//lib/json/common.rb#36
1389
+ def parser=(parser); end
1390
+
1391
+ # :call-seq:
1392
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
1393
+ #
1394
+ # Arguments +obj+ and +opts+ here are the same as
1395
+ # arguments +obj+ and +opts+ in JSON.generate.
1396
+ #
1397
+ # Default options are:
1398
+ # {
1399
+ # indent: ' ', # Two spaces
1400
+ # space: ' ', # One space
1401
+ # array_nl: "\n", # Newline
1402
+ # object_nl: "\n" # Newline
1403
+ # }
1404
+ #
1405
+ # Example:
1406
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
1407
+ # json = JSON.pretty_generate(obj)
1408
+ # puts json
1409
+ # Output:
1410
+ # {
1411
+ # "foo": [
1412
+ # "bar",
1413
+ # "baz"
1414
+ # ],
1415
+ # "bat": {
1416
+ # "bam": 0,
1417
+ # "bad": 1
1418
+ # }
1419
+ # }
1420
+ #
1421
+ # source://json//lib/json/common.rb#374
1422
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
1423
+
1424
+ # :stopdoc:
1425
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1426
+ #
1427
+ # source://json//lib/json/common.rb#374
1428
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
1429
+
1430
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1431
+ #
1432
+ # source://json//lib/json/common.rb#559
1433
+ def recurse_proc(result, &proc); end
1434
+
1435
+ # source://json//lib/json/common.rb#541
1436
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1437
+
1438
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1439
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1440
+ # JSON.state # => JSON::Ext::Generator::State
1441
+ #
1442
+ # source://json//lib/json/common.rb#112
1443
+ def state; end
1444
+
1445
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1446
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1447
+ # JSON.state # => JSON::Ext::Generator::State
1448
+ #
1449
+ # source://json//lib/json/common.rb#112
1450
+ def state=(_arg0); end
1451
+
1452
+ # :stopdoc:
1453
+ # I want to deprecate these later, so I'll first be silent about them, and
1454
+ # later delete them.
1455
+ #
1456
+ # source://json//lib/json/common.rb#300
1457
+ def unparse(obj, opts = T.unsafe(nil)); end
1458
+
1459
+ private
1460
+
1461
+ # source://json//lib/json/common.rb#643
1462
+ def merge_dump_options(opts, strict: T.unsafe(nil)); end
1463
+ end
1464
+ end
1465
+
1466
+ # source://json//lib/json/common.rb#118
1467
+ JSON::CREATE_ID_TLS_KEY = T.let(T.unsafe(nil), String)
1468
+
1469
+ # source://json//lib/json/common.rb#115
1470
+ JSON::DEFAULT_CREATE_ID = T.let(T.unsafe(nil), String)
1471
+
1472
+ # source://json//lib/json/generic_object.rb#9
1473
+ class JSON::GenericObject < ::OpenStruct
1474
+ # source://json//lib/json/generic_object.rb#67
1475
+ def as_json(*_arg0); end
1476
+
1477
+ # source://json//lib/json/generic_object.rb#51
1478
+ def to_hash; end
1479
+
1480
+ # source://json//lib/json/generic_object.rb#71
1481
+ def to_json(*a); end
1482
+
1483
+ # source://json//lib/json/generic_object.rb#63
1484
+ def |(other); end
1485
+
1486
+ class << self
1487
+ # source://json//lib/json/generic_object.rb#45
1488
+ def dump(obj, *args); end
1489
+
1490
+ # source://json//lib/json/generic_object.rb#25
1491
+ def from_hash(object); end
1492
+
1493
+ # Sets the attribute json_creatable
1494
+ #
1495
+ # @param value the value to set the attribute json_creatable to.
1496
+ #
1497
+ # source://json//lib/json/generic_object.rb#17
1498
+ def json_creatable=(_arg0); end
1499
+
1500
+ # @return [Boolean]
1501
+ #
1502
+ # source://json//lib/json/generic_object.rb#13
1503
+ def json_creatable?; end
1504
+
1505
+ # source://json//lib/json/generic_object.rb#19
1506
+ def json_create(data); end
1507
+
1508
+ # source://json//lib/json/generic_object.rb#40
1509
+ def load(source, proc = T.unsafe(nil), opts = T.unsafe(nil)); end
1510
+ end
1511
+ end
1512
+
1513
+ # The base exception for JSON errors.
1514
+ #
1515
+ # source://json//lib/json/common.rb#141
1516
+ class JSON::JSONError < ::StandardError
1517
+ class << self
1518
+ # source://json//lib/json/common.rb#142
1519
+ def wrap(exception); end
1520
+ end
1521
+ end
1522
+
1523
+ # source://json//lib/json/common.rb#7
1524
+ JSON::NOT_SET = T.let(T.unsafe(nil), Object)
1525
+
1526
+ # source://json//lib/json/common.rb#39
1527
+ JSON::Parser = JSON::Ext::Parser
1528
+
1529
+ # source://json//lib/json/common.rb#77
1530
+ JSON::State = JSON::Ext::Generator::State
1531
+
1532
+ # For backwards compatibility
1533
+ #
1534
+ # source://json//lib/json/common.rb#163
1535
+ JSON::UnparserError = JSON::GeneratorError
1536
+
1537
+ # source://json//lib/json/common.rb#653
1538
+ module Kernel
1539
+ private
1540
+
1541
+ # If _object_ is string-like, parse the string and return the parsed result as
1542
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
1543
+ # structure object and return it.
1544
+ #
1545
+ # The _opts_ argument is passed through to generate/parse respectively. See
1546
+ # generate and parse for their documentation.
1547
+ #
1548
+ # source://json//lib/json/common.rb#680
1549
+ def JSON(object, *args); end
1550
+
1551
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1552
+ # one line.
1553
+ #
1554
+ # source://json//lib/json/common.rb#658
1555
+ def j(*objs); end
1556
+
1557
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1558
+ # indentation and over many lines.
1559
+ #
1560
+ # source://json//lib/json/common.rb#667
1561
+ def jj(*objs); end
1562
+ end