type_toolkit 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +33 -0
  3. data/README.md +106 -15
  4. data/Rakefile +26 -2
  5. data/config/default.yml +4 -0
  6. data/lib/rubocop/cop/type_toolkit/dont_expect_unexpected_nil.rb +115 -0
  7. data/lib/rubocop-type_toolkit.rb +7 -0
  8. data/lib/type_toolkit/ext/nil_assertions.rb +36 -0
  9. data/lib/type_toolkit/version.rb +2 -1
  10. data/lib/type_toolkit.rb +2 -2
  11. data/sorbet/config +7 -0
  12. data/sorbet/rbi/annotations/.gitattributes +1 -0
  13. data/sorbet/rbi/annotations/minitest.rbi +120 -0
  14. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  15. data/sorbet/rbi/gems/.gitattributes +1 -0
  16. data/sorbet/rbi/gems/ast@2.4.3.rbi +586 -0
  17. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +637 -0
  18. data/sorbet/rbi/gems/date@3.5.1.rbi +403 -0
  19. data/sorbet/rbi/gems/erb@6.0.1.rbi +816 -0
  20. data/sorbet/rbi/gems/erubi@1.13.1.rbi +157 -0
  21. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  22. data/sorbet/rbi/gems/json@2.18.1.rbi +2340 -0
  23. data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
  24. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +119 -0
  25. data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
  26. data/sorbet/rbi/gems/minitest@5.27.0.rbi +1549 -0
  27. data/sorbet/rbi/gems/netrc@0.11.0.rbi +177 -0
  28. data/sorbet/rbi/gems/parallel@1.27.0.rbi +291 -0
  29. data/sorbet/rbi/gems/parser@3.3.10.2.rbi +5537 -0
  30. data/sorbet/rbi/gems/pp@0.6.3.rbi +376 -0
  31. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +477 -0
  32. data/sorbet/rbi/gems/prism@1.9.0.rbi +43414 -0
  33. data/sorbet/rbi/gems/psych@5.3.1.rbi +2542 -0
  34. data/sorbet/rbi/gems/racc@1.8.1.rbi +168 -0
  35. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
  36. data/sorbet/rbi/gems/rake@13.3.1.rbi +3036 -0
  37. data/sorbet/rbi/gems/rbi@0.3.9.rbi +5238 -0
  38. data/sorbet/rbi/gems/rbs@4.0.0.dev.5.rbi +8393 -0
  39. data/sorbet/rbi/gems/rdoc@7.2.0.rbi +13378 -0
  40. data/sorbet/rbi/gems/regexp_parser@2.11.3.rbi +3883 -0
  41. data/sorbet/rbi/gems/reline@0.6.3.rbi +2995 -0
  42. data/sorbet/rbi/gems/require-hooks@0.2.2.rbi +110 -0
  43. data/sorbet/rbi/gems/rexml@3.4.4.rbi +5258 -0
  44. data/sorbet/rbi/gems/rubocop-ast@1.49.0.rbi +7456 -0
  45. data/sorbet/rbi/gems/rubocop-minitest@0.38.2.rbi +2649 -0
  46. data/sorbet/rbi/gems/rubocop-rake@0.7.1.rbi +328 -0
  47. data/sorbet/rbi/gems/rubocop-shopify@2.18.0.rbi +9 -0
  48. data/sorbet/rbi/gems/rubocop@1.84.2.rbi +64803 -0
  49. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  50. data/sorbet/rbi/gems/spoom@1.7.11.rbi +5878 -0
  51. data/sorbet/rbi/gems/stringio@3.2.0.rbi +9 -0
  52. data/sorbet/rbi/gems/tapioca@0.17.10.rbi +3513 -0
  53. data/sorbet/rbi/gems/thor@1.5.0.rbi +4476 -0
  54. data/sorbet/rbi/gems/tsort@0.2.0.rbi +393 -0
  55. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +132 -0
  56. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +254 -0
  57. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +430 -0
  58. data/sorbet/rbi/gems/yard@0.9.38.rbi +18425 -0
  59. data/sorbet/rbi/shims/lint_roller.rbi +6 -0
  60. data/sorbet/rbi/shims/minitest.rbi +43 -0
  61. data/sorbet/rbi/shims/rubocop_minitest.rbi +17 -0
  62. data/sorbet/rbi/todo.rbi +5 -0
  63. data/sorbet/tapioca/config.yml +13 -0
  64. data/sorbet/tapioca/require.rb +5 -0
  65. data/spec/.rubocop.yml +13 -0
  66. data/spec/nil_assertions_spec.rb +19 -0
  67. data/spec/rubocop/cop/type_toolkit/dont_expect_unexpected_nil_spec.rb +194 -0
  68. data/spec/spec_helper.rb +8 -0
  69. data/spec/type_toolkit_spec.rb +11 -0
  70. metadata +65 -1
@@ -0,0 +1,2340 @@
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
+ class Array
9
+ include ::Enumerable
10
+ include ::JSON::Ext::Generator::GeneratorMethods::Array
11
+ end
12
+
13
+ class FalseClass
14
+ include ::JSON::Ext::Generator::GeneratorMethods::FalseClass
15
+ end
16
+
17
+ class Float < ::Numeric
18
+ include ::JSON::Ext::Generator::GeneratorMethods::Float
19
+ end
20
+
21
+ class Hash
22
+ include ::Enumerable
23
+ include ::JSON::Ext::Generator::GeneratorMethods::Hash
24
+ end
25
+
26
+ class Integer < ::Numeric
27
+ include ::JSON::Ext::Generator::GeneratorMethods::Integer
28
+ end
29
+
30
+ # = JavaScript \Object Notation (\JSON)
31
+ #
32
+ # \JSON is a lightweight data-interchange format.
33
+ #
34
+ # \JSON is easy for us humans to read and write,
35
+ # and equally simple for machines to read (parse) and write (generate).
36
+ #
37
+ # \JSON is language-independent, making it an ideal interchange format
38
+ # for applications in differing programming languages
39
+ # and on differing operating systems.
40
+ #
41
+ # == \JSON Values
42
+ #
43
+ # A \JSON value is one of the following:
44
+ # - Double-quoted text: <tt>"foo"</tt>.
45
+ # - Number: +1+, +1.0+, +2.0e2+.
46
+ # - Boolean: +true+, +false+.
47
+ # - Null: +null+.
48
+ # - \Array: an ordered list of values, enclosed by square brackets:
49
+ # ["foo", 1, 1.0, 2.0e2, true, false, null]
50
+ #
51
+ # - \Object: a collection of name/value pairs, enclosed by curly braces;
52
+ # each name is double-quoted text;
53
+ # the values may be any \JSON values:
54
+ # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
55
+ #
56
+ # A \JSON array or object may contain nested arrays, objects, and scalars
57
+ # to any depth:
58
+ # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
59
+ # [{"foo": 0, "bar": 1}, ["baz", 2]]
60
+ #
61
+ # == Using \Module \JSON
62
+ #
63
+ # To make module \JSON available in your code, begin with:
64
+ # require 'json'
65
+ #
66
+ # All examples here assume that this has been done.
67
+ #
68
+ # === Parsing \JSON
69
+ #
70
+ # You can parse a \String containing \JSON data using
71
+ # either of two methods:
72
+ # - <tt>JSON.parse(source, opts)</tt>
73
+ # - <tt>JSON.parse!(source, opts)</tt>
74
+ #
75
+ # where
76
+ # - +source+ is a Ruby object.
77
+ # - +opts+ is a \Hash object containing options
78
+ # that control both input allowed and output formatting.
79
+ #
80
+ # The difference between the two methods
81
+ # is that JSON.parse! omits some checks
82
+ # and may not be safe for some +source+ data;
83
+ # use it only for data from trusted sources.
84
+ # Use the safer method JSON.parse for less trusted sources.
85
+ #
86
+ # ==== Parsing \JSON Arrays
87
+ #
88
+ # When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:
89
+ # json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
90
+ # ruby = JSON.parse(json)
91
+ # ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
92
+ # ruby.class # => Array
93
+ #
94
+ # The \JSON array may contain nested arrays, objects, and scalars
95
+ # to any depth:
96
+ # json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
97
+ # JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
98
+ #
99
+ # ==== Parsing \JSON \Objects
100
+ #
101
+ # When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:
102
+ # json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
103
+ # ruby = JSON.parse(json)
104
+ # ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
105
+ # ruby.class # => Hash
106
+ #
107
+ # The \JSON object may contain nested arrays, objects, and scalars
108
+ # to any depth:
109
+ # json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
110
+ # JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
111
+ #
112
+ # ==== Parsing \JSON Scalars
113
+ #
114
+ # When the source is a \JSON scalar (not an array or object),
115
+ # JSON.parse returns a Ruby scalar.
116
+ #
117
+ # \String:
118
+ # ruby = JSON.parse('"foo"')
119
+ # ruby # => 'foo'
120
+ # ruby.class # => String
121
+ # \Integer:
122
+ # ruby = JSON.parse('1')
123
+ # ruby # => 1
124
+ # ruby.class # => Integer
125
+ # \Float:
126
+ # ruby = JSON.parse('1.0')
127
+ # ruby # => 1.0
128
+ # ruby.class # => Float
129
+ # ruby = JSON.parse('2.0e2')
130
+ # ruby # => 200
131
+ # ruby.class # => Float
132
+ # Boolean:
133
+ # ruby = JSON.parse('true')
134
+ # ruby # => true
135
+ # ruby.class # => TrueClass
136
+ # ruby = JSON.parse('false')
137
+ # ruby # => false
138
+ # ruby.class # => FalseClass
139
+ # Null:
140
+ # ruby = JSON.parse('null')
141
+ # ruby # => nil
142
+ # ruby.class # => NilClass
143
+ #
144
+ # ==== Parsing Options
145
+ #
146
+ # ====== Input Options
147
+ #
148
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed;
149
+ # defaults to +100+; specify +false+ to disable depth checking.
150
+ #
151
+ # With the default, +false+:
152
+ # source = '[0, [1, [2, [3]]]]'
153
+ # ruby = JSON.parse(source)
154
+ # ruby # => [0, [1, [2, [3]]]]
155
+ # Too deep:
156
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
157
+ # JSON.parse(source, {max_nesting: 1})
158
+ # Bad value:
159
+ # # Raises TypeError (wrong argument type Symbol (expected Fixnum)):
160
+ # JSON.parse(source, {max_nesting: :foo})
161
+ #
162
+ # ---
163
+ #
164
+ # Option +allow_duplicate_key+ specifies whether duplicate keys in objects
165
+ # should be ignored or cause an error to be raised:
166
+ #
167
+ # When not specified:
168
+ # # The last value is used and a deprecation warning emitted.
169
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
170
+ # # warning: detected duplicate keys in JSON object.
171
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
172
+ #
173
+ # When set to `+true+`
174
+ # # The last value is used.
175
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
176
+ #
177
+ # When set to `+false+`, the future default:
178
+ # JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
179
+ #
180
+ # ---
181
+ #
182
+ # Option +allow_nan+ (boolean) specifies whether to allow
183
+ # NaN, Infinity, and MinusInfinity in +source+;
184
+ # defaults to +false+.
185
+ #
186
+ # With the default, +false+:
187
+ # # Raises JSON::ParserError (225: unexpected token at '[NaN]'):
188
+ # JSON.parse('[NaN]')
189
+ # # Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
190
+ # JSON.parse('[Infinity]')
191
+ # # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
192
+ # JSON.parse('[-Infinity]')
193
+ # Allow:
194
+ # source = '[NaN, Infinity, -Infinity]'
195
+ # ruby = JSON.parse(source, {allow_nan: true})
196
+ # ruby # => [NaN, Infinity, -Infinity]
197
+ #
198
+ # ---
199
+ #
200
+ # Option +allow_trailing_comma+ (boolean) specifies whether to allow
201
+ # trailing commas in objects and arrays;
202
+ # defaults to +false+.
203
+ #
204
+ # With the default, +false+:
205
+ # JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
206
+ #
207
+ # When enabled:
208
+ # JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
209
+ #
210
+ # ---
211
+ #
212
+ # Option +allow_control_characters+ (boolean) specifies whether to allow
213
+ # unescaped ASCII control characters, such as newlines, in strings;
214
+ # defaults to +false+.
215
+ #
216
+ # With the default, +false+:
217
+ # JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
218
+ #
219
+ # When enabled:
220
+ # JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
221
+ #
222
+ # ====== Output Options
223
+ #
224
+ # Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
225
+ # defaults to +false+.
226
+ #
227
+ # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
228
+ # should be Symbols;
229
+ # defaults to +false+ (use Strings).
230
+ #
231
+ # With the default, +false+:
232
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
233
+ # ruby = JSON.parse(source)
234
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
235
+ # Use Symbols:
236
+ # ruby = JSON.parse(source, {symbolize_names: true})
237
+ # ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
238
+ #
239
+ # ---
240
+ #
241
+ # Option +object_class+ (\Class) specifies the Ruby class to be used
242
+ # for each \JSON object;
243
+ # defaults to \Hash.
244
+ #
245
+ # With the default, \Hash:
246
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
247
+ # ruby = JSON.parse(source)
248
+ # ruby.class # => Hash
249
+ # Use class \OpenStruct:
250
+ # ruby = JSON.parse(source, {object_class: OpenStruct})
251
+ # ruby # => #<OpenStruct a="foo", b=1.0, c=true, d=false, e=nil>
252
+ #
253
+ # ---
254
+ #
255
+ # Option +array_class+ (\Class) specifies the Ruby class to be used
256
+ # for each \JSON array;
257
+ # defaults to \Array.
258
+ #
259
+ # With the default, \Array:
260
+ # source = '["foo", 1.0, true, false, null]'
261
+ # ruby = JSON.parse(source)
262
+ # ruby.class # => Array
263
+ # Use class \Set:
264
+ # ruby = JSON.parse(source, {array_class: Set})
265
+ # ruby # => #<Set: {"foo", 1.0, true, false, nil}>
266
+ #
267
+ # ---
268
+ #
269
+ # Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing.
270
+ # See {\JSON Additions}[#module-JSON-label-JSON+Additions].
271
+ #
272
+ # === Generating \JSON
273
+ #
274
+ # To generate a Ruby \String containing \JSON data,
275
+ # use method <tt>JSON.generate(source, opts)</tt>, where
276
+ # - +source+ is a Ruby object.
277
+ # - +opts+ is a \Hash object containing options
278
+ # that control both input allowed and output formatting.
279
+ #
280
+ # ==== Generating \JSON from Arrays
281
+ #
282
+ # When the source is a Ruby \Array, JSON.generate returns
283
+ # a \String containing a \JSON array:
284
+ # ruby = [0, 's', :foo]
285
+ # json = JSON.generate(ruby)
286
+ # json # => '[0,"s","foo"]'
287
+ #
288
+ # The Ruby \Array array may contain nested arrays, hashes, and scalars
289
+ # to any depth:
290
+ # ruby = [0, [1, 2], {foo: 3, bar: 4}]
291
+ # json = JSON.generate(ruby)
292
+ # json # => '[0,[1,2],{"foo":3,"bar":4}]'
293
+ #
294
+ # ==== Generating \JSON from Hashes
295
+ #
296
+ # When the source is a Ruby \Hash, JSON.generate returns
297
+ # a \String containing a \JSON object:
298
+ # ruby = {foo: 0, bar: 's', baz: :bat}
299
+ # json = JSON.generate(ruby)
300
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
301
+ #
302
+ # The Ruby \Hash array may contain nested arrays, hashes, and scalars
303
+ # to any depth:
304
+ # ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
305
+ # json = JSON.generate(ruby)
306
+ # json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
307
+ #
308
+ # ==== Generating \JSON from Other Objects
309
+ #
310
+ # When the source is neither an \Array nor a \Hash,
311
+ # the generated \JSON data depends on the class of the source.
312
+ #
313
+ # When the source is a Ruby \Integer or \Float, JSON.generate returns
314
+ # a \String containing a \JSON number:
315
+ # JSON.generate(42) # => '42'
316
+ # JSON.generate(0.42) # => '0.42'
317
+ #
318
+ # When the source is a Ruby \String, JSON.generate returns
319
+ # a \String containing a \JSON string (with double-quotes):
320
+ # JSON.generate('A string') # => '"A string"'
321
+ #
322
+ # When the source is +true+, +false+ or +nil+, JSON.generate returns
323
+ # a \String containing the corresponding \JSON token:
324
+ # JSON.generate(true) # => 'true'
325
+ # JSON.generate(false) # => 'false'
326
+ # JSON.generate(nil) # => 'null'
327
+ #
328
+ # When the source is none of the above, JSON.generate returns
329
+ # a \String containing a \JSON string representation of the source:
330
+ # JSON.generate(:foo) # => '"foo"'
331
+ # JSON.generate(Complex(0, 0)) # => '"0+0i"'
332
+ # JSON.generate(Dir.new('.')) # => '"#<Dir>"'
333
+ #
334
+ # ==== Generating Options
335
+ #
336
+ # ====== Input Options
337
+ #
338
+ # Option +allow_nan+ (boolean) specifies whether
339
+ # +NaN+, +Infinity+, and <tt>-Infinity</tt> may be generated;
340
+ # defaults to +false+.
341
+ #
342
+ # With the default, +false+:
343
+ # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
344
+ # JSON.generate(JSON::NaN)
345
+ # # Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
346
+ # JSON.generate(JSON::Infinity)
347
+ # # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
348
+ # JSON.generate(JSON::MinusInfinity)
349
+ #
350
+ # Allow:
351
+ # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
352
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
353
+ #
354
+ # ---
355
+ #
356
+ # Option +allow_duplicate_key+ (boolean) specifies whether
357
+ # hashes with duplicate keys should be allowed or produce an error.
358
+ # defaults to emit a deprecation warning.
359
+ #
360
+ # With the default, (not set):
361
+ # Warning[:deprecated] = true
362
+ # JSON.generate({ foo: 1, "foo" => 2 })
363
+ # # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
364
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
365
+ # # => '{"foo":1,"foo":2}'
366
+ #
367
+ # With <tt>false</tt>
368
+ # JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
369
+ # # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
370
+ #
371
+ # In version 3.0, <tt>false</tt> will become the default.
372
+ #
373
+ # ---
374
+ #
375
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth
376
+ # in +obj+; defaults to +100+.
377
+ #
378
+ # With the default, +100+:
379
+ # obj = [[[[[[0]]]]]]
380
+ # JSON.generate(obj) # => '[[[[[[0]]]]]]'
381
+ #
382
+ # Too deep:
383
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
384
+ # JSON.generate(obj, max_nesting: 2)
385
+ #
386
+ # ====== Escaping Options
387
+ #
388
+ # Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
389
+ # and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
390
+ # tags.
391
+ #
392
+ # Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
393
+ # should be escaped.
394
+ #
395
+ # ====== Output Options
396
+ #
397
+ # The default formatting options generate the most compact
398
+ # \JSON data, all on one line and with no whitespace.
399
+ #
400
+ # You can use these formatting options to generate
401
+ # \JSON data in a more open format, using whitespace.
402
+ # See also JSON.pretty_generate.
403
+ #
404
+ # - Option +array_nl+ (\String) specifies a string (usually a newline)
405
+ # to be inserted after each \JSON array; defaults to the empty \String, <tt>''</tt>.
406
+ # - Option +object_nl+ (\String) specifies a string (usually a newline)
407
+ # to be inserted after each \JSON object; defaults to the empty \String, <tt>''</tt>.
408
+ # - Option +indent+ (\String) specifies the string (usually spaces) to be
409
+ # used for indentation; defaults to the empty \String, <tt>''</tt>;
410
+ # defaults to the empty \String, <tt>''</tt>;
411
+ # has no effect unless options +array_nl+ or +object_nl+ specify newlines.
412
+ # - Option +space+ (\String) specifies a string (usually a space) to be
413
+ # inserted after the colon in each \JSON object's pair;
414
+ # defaults to the empty \String, <tt>''</tt>.
415
+ # - Option +space_before+ (\String) specifies a string (usually a space) to be
416
+ # inserted before the colon in each \JSON object's pair;
417
+ # defaults to the empty \String, <tt>''</tt>.
418
+ #
419
+ # In this example, +obj+ is used first to generate the shortest
420
+ # \JSON data (no whitespace), then again with all formatting options
421
+ # specified:
422
+ #
423
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
424
+ # json = JSON.generate(obj)
425
+ # puts 'Compact:', json
426
+ # opts = {
427
+ # array_nl: "\n",
428
+ # object_nl: "\n",
429
+ # indent: ' ',
430
+ # space_before: ' ',
431
+ # space: ' '
432
+ # }
433
+ # puts 'Open:', JSON.generate(obj, opts)
434
+ #
435
+ # Output:
436
+ # Compact:
437
+ # {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
438
+ # Open:
439
+ # {
440
+ # "foo" : [
441
+ # "bar",
442
+ # "baz"
443
+ # ],
444
+ # "bat" : {
445
+ # "bam" : 0,
446
+ # "bad" : 1
447
+ # }
448
+ # }
449
+ #
450
+ # == \JSON Additions
451
+ #
452
+ # Note that JSON Additions must only be used with trusted data, and is
453
+ # deprecated.
454
+ #
455
+ # When you "round trip" a non-\String object from Ruby to \JSON and back,
456
+ # you have a new \String, instead of the object you began with:
457
+ # ruby0 = Range.new(0, 2)
458
+ # json = JSON.generate(ruby0)
459
+ # json # => '0..2"'
460
+ # ruby1 = JSON.parse(json)
461
+ # ruby1 # => '0..2'
462
+ # ruby1.class # => String
463
+ #
464
+ # You can use \JSON _additions_ to preserve the original object.
465
+ # The addition is an extension of a ruby class, so that:
466
+ # - \JSON.generate stores more information in the \JSON string.
467
+ # - \JSON.parse, called with option +create_additions+,
468
+ # uses that information to create a proper Ruby object.
469
+ #
470
+ # This example shows a \Range being generated into \JSON
471
+ # and parsed back into Ruby, both without and with
472
+ # the addition for \Range:
473
+ # ruby = Range.new(0, 2)
474
+ # # This passage does not use the addition for Range.
475
+ # json0 = JSON.generate(ruby)
476
+ # ruby0 = JSON.parse(json0)
477
+ # # This passage uses the addition for Range.
478
+ # require 'json/add/range'
479
+ # json1 = JSON.generate(ruby)
480
+ # ruby1 = JSON.parse(json1, create_additions: true)
481
+ # # Make a nice display.
482
+ # display = <<~EOT
483
+ # Generated JSON:
484
+ # Without addition: #{json0} (#{json0.class})
485
+ # With addition: #{json1} (#{json1.class})
486
+ # Parsed JSON:
487
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
488
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
489
+ # EOT
490
+ # puts display
491
+ #
492
+ # This output shows the different results:
493
+ # Generated JSON:
494
+ # Without addition: "0..2" (String)
495
+ # With addition: {"json_class":"Range","a":[0,2,false]} (String)
496
+ # Parsed JSON:
497
+ # Without addition: "0..2" (String)
498
+ # With addition: 0..2 (Range)
499
+ #
500
+ # The \JSON module includes additions for certain classes.
501
+ # You can also craft custom additions.
502
+ # See {Custom \JSON Additions}[#module-JSON-label-Custom+JSON+Additions].
503
+ #
504
+ # === Built-in Additions
505
+ #
506
+ # The \JSON module includes additions for certain classes.
507
+ # To use an addition, +require+ its source:
508
+ # - BigDecimal: <tt>require 'json/add/bigdecimal'</tt>
509
+ # - Complex: <tt>require 'json/add/complex'</tt>
510
+ # - Date: <tt>require 'json/add/date'</tt>
511
+ # - DateTime: <tt>require 'json/add/date_time'</tt>
512
+ # - Exception: <tt>require 'json/add/exception'</tt>
513
+ # - OpenStruct: <tt>require 'json/add/ostruct'</tt>
514
+ # - Range: <tt>require 'json/add/range'</tt>
515
+ # - Rational: <tt>require 'json/add/rational'</tt>
516
+ # - Regexp: <tt>require 'json/add/regexp'</tt>
517
+ # - Set: <tt>require 'json/add/set'</tt>
518
+ # - Struct: <tt>require 'json/add/struct'</tt>
519
+ # - Symbol: <tt>require 'json/add/symbol'</tt>
520
+ # - Time: <tt>require 'json/add/time'</tt>
521
+ #
522
+ # To reduce punctuation clutter, the examples below
523
+ # show the generated \JSON via +puts+, rather than the usual +inspect+,
524
+ #
525
+ # \BigDecimal:
526
+ # require 'json/add/bigdecimal'
527
+ # ruby0 = BigDecimal(0) # 0.0
528
+ # json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"}
529
+ # ruby1 = JSON.parse(json, create_additions: true) # 0.0
530
+ # ruby1.class # => BigDecimal
531
+ #
532
+ # \Complex:
533
+ # require 'json/add/complex'
534
+ # ruby0 = Complex(1+0i) # 1+0i
535
+ # json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0}
536
+ # ruby1 = JSON.parse(json, create_additions: true) # 1+0i
537
+ # ruby1.class # Complex
538
+ #
539
+ # \Date:
540
+ # require 'json/add/date'
541
+ # ruby0 = Date.today # 2020-05-02
542
+ # json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0}
543
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02
544
+ # ruby1.class # Date
545
+ #
546
+ # \DateTime:
547
+ # require 'json/add/date_time'
548
+ # ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00
549
+ # 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}
550
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00
551
+ # ruby1.class # DateTime
552
+ #
553
+ # \Exception (and its subclasses including \RuntimeError):
554
+ # require 'json/add/exception'
555
+ # ruby0 = Exception.new('A message') # A message
556
+ # json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null}
557
+ # ruby1 = JSON.parse(json, create_additions: true) # A message
558
+ # ruby1.class # Exception
559
+ # ruby0 = RuntimeError.new('Another message') # Another message
560
+ # json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null}
561
+ # ruby1 = JSON.parse(json, create_additions: true) # Another message
562
+ # ruby1.class # RuntimeError
563
+ #
564
+ # \OpenStruct:
565
+ # require 'json/add/ostruct'
566
+ # ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # #<OpenStruct name="Matz", language="Ruby">
567
+ # json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}}
568
+ # ruby1 = JSON.parse(json, create_additions: true) # #<OpenStruct name="Matz", language="Ruby">
569
+ # ruby1.class # OpenStruct
570
+ #
571
+ # \Range:
572
+ # require 'json/add/range'
573
+ # ruby0 = Range.new(0, 2) # 0..2
574
+ # json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]}
575
+ # ruby1 = JSON.parse(json, create_additions: true) # 0..2
576
+ # ruby1.class # Range
577
+ #
578
+ # \Rational:
579
+ # require 'json/add/rational'
580
+ # ruby0 = Rational(1, 3) # 1/3
581
+ # json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3}
582
+ # ruby1 = JSON.parse(json, create_additions: true) # 1/3
583
+ # ruby1.class # Rational
584
+ #
585
+ # \Regexp:
586
+ # require 'json/add/regexp'
587
+ # ruby0 = Regexp.new('foo') # (?-mix:foo)
588
+ # json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"}
589
+ # ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo)
590
+ # ruby1.class # Regexp
591
+ #
592
+ # \Set:
593
+ # require 'json/add/set'
594
+ # ruby0 = Set.new([0, 1, 2]) # #<Set: {0, 1, 2}>
595
+ # json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]}
596
+ # ruby1 = JSON.parse(json, create_additions: true) # #<Set: {0, 1, 2}>
597
+ # ruby1.class # Set
598
+ #
599
+ # \Struct:
600
+ # require 'json/add/struct'
601
+ # Customer = Struct.new(:name, :address) # Customer
602
+ # ruby0 = Customer.new("Dave", "123 Main") # #<struct Customer name="Dave", address="123 Main">
603
+ # json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]}
604
+ # ruby1 = JSON.parse(json, create_additions: true) # #<struct Customer name="Dave", address="123 Main">
605
+ # ruby1.class # Customer
606
+ #
607
+ # \Symbol:
608
+ # require 'json/add/symbol'
609
+ # ruby0 = :foo # foo
610
+ # json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"}
611
+ # ruby1 = JSON.parse(json, create_additions: true) # foo
612
+ # ruby1.class # Symbol
613
+ #
614
+ # \Time:
615
+ # require 'json/add/time'
616
+ # ruby0 = Time.now # 2020-05-02 11:28:26 -0500
617
+ # json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000}
618
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500
619
+ # ruby1.class # Time
620
+ #
621
+ #
622
+ # === Custom \JSON Additions
623
+ #
624
+ # In addition to the \JSON additions provided,
625
+ # you can craft \JSON additions of your own,
626
+ # either for Ruby built-in classes or for user-defined classes.
627
+ #
628
+ # Here's a user-defined class +Foo+:
629
+ # class Foo
630
+ # attr_accessor :bar, :baz
631
+ # def initialize(bar, baz)
632
+ # self.bar = bar
633
+ # self.baz = baz
634
+ # end
635
+ # end
636
+ #
637
+ # Here's the \JSON addition for it:
638
+ # # Extend class Foo with JSON addition.
639
+ # class Foo
640
+ # # Serialize Foo object with its class name and arguments
641
+ # def to_json(*args)
642
+ # {
643
+ # JSON.create_id => self.class.name,
644
+ # 'a' => [ bar, baz ]
645
+ # }.to_json(*args)
646
+ # end
647
+ # # Deserialize JSON string by constructing new Foo object with arguments.
648
+ # def self.json_create(object)
649
+ # new(*object['a'])
650
+ # end
651
+ # end
652
+ #
653
+ # Demonstration:
654
+ # require 'json'
655
+ # # This Foo object has no custom addition.
656
+ # foo0 = Foo.new(0, 1)
657
+ # json0 = JSON.generate(foo0)
658
+ # obj0 = JSON.parse(json0)
659
+ # # Lood the custom addition.
660
+ # require_relative 'foo_addition'
661
+ # # This foo has the custom addition.
662
+ # foo1 = Foo.new(0, 1)
663
+ # json1 = JSON.generate(foo1)
664
+ # obj1 = JSON.parse(json1, create_additions: true)
665
+ # # Make a nice display.
666
+ # display = <<~EOT
667
+ # Generated JSON:
668
+ # Without custom addition: #{json0} (#{json0.class})
669
+ # With custom addition: #{json1} (#{json1.class})
670
+ # Parsed JSON:
671
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
672
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
673
+ # EOT
674
+ # puts display
675
+ #
676
+ # Output:
677
+ #
678
+ # Generated JSON:
679
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
680
+ # With custom addition: {"json_class":"Foo","a":[0,1]} (String)
681
+ # Parsed JSON:
682
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
683
+ # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
684
+ #
685
+ # source://json//lib/json/version.rb#3
686
+ module JSON
687
+ private
688
+
689
+ # :call-seq:
690
+ # JSON.dump(obj, io = nil, limit = nil)
691
+ #
692
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
693
+ #
694
+ # The default options can be changed via method JSON.dump_default_options.
695
+ #
696
+ # - Argument +io+, if given, should respond to method +write+;
697
+ # the \JSON \String is written to +io+, and +io+ is returned.
698
+ # If +io+ is not given, the \JSON \String is returned.
699
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
700
+ #
701
+ # ---
702
+ #
703
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
704
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
705
+ # json = JSON.dump(obj)
706
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
707
+ #
708
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
709
+ # path = 't.json'
710
+ # File.open(path, 'w') do |file|
711
+ # JSON.dump(obj, file)
712
+ # end # => #<File:t.json (closed)>
713
+ # puts File.read(path)
714
+ # Output:
715
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
716
+ #
717
+ # source://json//lib/json/common.rb#930
718
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
719
+
720
+ # :call-seq:
721
+ # JSON.fast_generate(obj, opts) -> new_string
722
+ #
723
+ # Arguments +obj+ and +opts+ here are the same as
724
+ # arguments +obj+ and +opts+ in JSON.generate.
725
+ #
726
+ # By default, generates \JSON data without checking
727
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
728
+ #
729
+ # Raises an exception if +obj+ contains circular references:
730
+ # a = []; b = []; a.push(b); b.push(a)
731
+ # # Raises SystemStackError (stack level too deep):
732
+ # JSON.fast_generate(a)
733
+ #
734
+ # source://json//lib/json/common.rb#460
735
+ def fast_generate(obj, opts = T.unsafe(nil)); end
736
+
737
+ # source://json//lib/json/common.rb#975
738
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
739
+
740
+ # :call-seq:
741
+ # JSON.generate(obj, opts = nil) -> new_string
742
+ #
743
+ # Returns a \String containing the generated \JSON data.
744
+ #
745
+ # See also JSON.pretty_generate.
746
+ #
747
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
748
+ #
749
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
750
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
751
+ #
752
+ # ---
753
+ #
754
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
755
+ # obj = ["foo", 1.0, true, false, nil]
756
+ # json = JSON.generate(obj)
757
+ # json # => '["foo",1.0,true,false,null]'
758
+ #
759
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
760
+ # obj = {foo: 0, bar: 's', baz: :bat}
761
+ # json = JSON.generate(obj)
762
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
763
+ #
764
+ # For examples of generating from other Ruby objects, see
765
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
766
+ #
767
+ # ---
768
+ #
769
+ # Raises an exception if any formatting option is not a \String.
770
+ #
771
+ # Raises an exception if +obj+ contains circular references:
772
+ # a = []; b = []; a.push(b); b.push(a)
773
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
774
+ # JSON.generate(a)
775
+ #
776
+ # source://json//lib/json/common.rb#439
777
+ def generate(obj, opts = T.unsafe(nil)); end
778
+
779
+ # :call-seq:
780
+ # JSON.load(source, options = {}) -> object
781
+ # JSON.load(source, proc = nil, options = {}) -> object
782
+ #
783
+ # Returns the Ruby objects created by parsing the given +source+.
784
+ #
785
+ # BEWARE: This method is meant to serialise data from trusted user input,
786
+ # like from your own database server or clients under your control, it could
787
+ # be dangerous to allow untrusted users to pass JSON sources into it.
788
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
789
+ #
790
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
791
+ # non native type is deserialized, without `create_additions` being explicitly
792
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
793
+ # by default.
794
+ #
795
+ # - Argument +source+ must be, or be convertible to, a \String:
796
+ # - If +source+ responds to instance method +to_str+,
797
+ # <tt>source.to_str</tt> becomes the source.
798
+ # - If +source+ responds to instance method +to_io+,
799
+ # <tt>source.to_io.read</tt> becomes the source.
800
+ # - If +source+ responds to instance method +read+,
801
+ # <tt>source.read</tt> becomes the source.
802
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
803
+ # - Option +allow_blank+ specifies a truthy value.
804
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
805
+ # - Otherwise, +source+ remains the source.
806
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
807
+ # It will be called recursively with each result (depth-first order).
808
+ # See details below.
809
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
810
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
811
+ # The default options can be changed via method JSON.load_default_options=.
812
+ #
813
+ # ---
814
+ #
815
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
816
+ # <tt>parse(source, opts)</tt>; see #parse.
817
+ #
818
+ # Source for following examples:
819
+ # source = <<~JSON
820
+ # {
821
+ # "name": "Dave",
822
+ # "age" :40,
823
+ # "hats": [
824
+ # "Cattleman's",
825
+ # "Panama",
826
+ # "Tophat"
827
+ # ]
828
+ # }
829
+ # JSON
830
+ #
831
+ # Load a \String:
832
+ # ruby = JSON.load(source)
833
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
834
+ #
835
+ # Load an \IO object:
836
+ # require 'stringio'
837
+ # object = JSON.load(StringIO.new(source))
838
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
839
+ #
840
+ # Load a \File object:
841
+ # path = 't.json'
842
+ # File.write(path, source)
843
+ # File.open(path) do |file|
844
+ # JSON.load(file)
845
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
846
+ #
847
+ # ---
848
+ #
849
+ # When +proc+ is given:
850
+ # - Modifies +source+ as above.
851
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
852
+ # - Recursively calls <tt>proc(result)</tt>.
853
+ # - Returns the final result.
854
+ #
855
+ # Example:
856
+ # require 'json'
857
+ #
858
+ # # Some classes for the example.
859
+ # class Base
860
+ # def initialize(attributes)
861
+ # @attributes = attributes
862
+ # end
863
+ # end
864
+ # class User < Base; end
865
+ # class Account < Base; end
866
+ # class Admin < Base; end
867
+ # # The JSON source.
868
+ # json = <<-EOF
869
+ # {
870
+ # "users": [
871
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
872
+ # {"type": "User", "username": "john", "email": "john@example.com"}
873
+ # ],
874
+ # "accounts": [
875
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
876
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
877
+ # ],
878
+ # "admins": {"type": "Admin", "password": "0wn3d"}
879
+ # }
880
+ # EOF
881
+ # # Deserializer method.
882
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
883
+ # type = obj.is_a?(Hash) && obj["type"]
884
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
885
+ # end
886
+ # # Call to JSON.load
887
+ # ruby = JSON.load(json, proc {|obj|
888
+ # case obj
889
+ # when Hash
890
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
891
+ # when Array
892
+ # obj.map! {|v| deserialize_obj v }
893
+ # end
894
+ # obj
895
+ # })
896
+ # pp ruby
897
+ # Output:
898
+ # {"users"=>
899
+ # [#<User:0x00000000064c4c98
900
+ # @attributes=
901
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
902
+ # #<User:0x00000000064c4bd0
903
+ # @attributes=
904
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
905
+ # "accounts"=>
906
+ # [{"account"=>
907
+ # #<Account:0x00000000064c4928
908
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
909
+ # {"account"=>
910
+ # #<Account:0x00000000064c4680
911
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
912
+ # "admins"=>
913
+ # #<Admin:0x00000000064c41f8
914
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
915
+ #
916
+ # source://json//lib/json/common.rb#854
917
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
918
+
919
+ # :call-seq:
920
+ # JSON.load_file(path, opts={}) -> object
921
+ #
922
+ # Calls:
923
+ # parse(File.read(path), opts)
924
+ #
925
+ # See method #parse.
926
+ #
927
+ # source://json//lib/json/common.rb#388
928
+ def load_file(filespec, opts = T.unsafe(nil)); end
929
+
930
+ # :call-seq:
931
+ # JSON.load_file!(path, opts = {})
932
+ #
933
+ # Calls:
934
+ # JSON.parse!(File.read(path, opts))
935
+ #
936
+ # See method #parse!
937
+ #
938
+ # source://json//lib/json/common.rb#399
939
+ def load_file!(filespec, opts = T.unsafe(nil)); end
940
+
941
+ # :call-seq:
942
+ # JSON.parse(source, opts) -> object
943
+ #
944
+ # Returns the Ruby objects created by parsing the given +source+.
945
+ #
946
+ # Argument +source+ contains the \String to be parsed.
947
+ #
948
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
949
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
950
+ #
951
+ # ---
952
+ #
953
+ # When +source+ is a \JSON array, returns a Ruby \Array:
954
+ # source = '["foo", 1.0, true, false, null]'
955
+ # ruby = JSON.parse(source)
956
+ # ruby # => ["foo", 1.0, true, false, nil]
957
+ # ruby.class # => Array
958
+ #
959
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
960
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
961
+ # ruby = JSON.parse(source)
962
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
963
+ # ruby.class # => Hash
964
+ #
965
+ # For examples of parsing for all \JSON data types, see
966
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
967
+ #
968
+ # Parses nested JSON objects:
969
+ # source = <<~JSON
970
+ # {
971
+ # "name": "Dave",
972
+ # "age" :40,
973
+ # "hats": [
974
+ # "Cattleman's",
975
+ # "Panama",
976
+ # "Tophat"
977
+ # ]
978
+ # }
979
+ # JSON
980
+ # ruby = JSON.parse(source)
981
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
982
+ #
983
+ # ---
984
+ #
985
+ # Raises an exception if +source+ is not valid JSON:
986
+ # # Raises JSON::ParserError (783: unexpected token at ''):
987
+ # JSON.parse('')
988
+ #
989
+ # source://json//lib/json/common.rb#351
990
+ def parse(source, opts = T.unsafe(nil)); end
991
+
992
+ # :call-seq:
993
+ # JSON.parse!(source, opts) -> object
994
+ #
995
+ # Calls
996
+ # parse(source, opts)
997
+ # with +source+ and possibly modified +opts+.
998
+ #
999
+ # Differences from JSON.parse:
1000
+ # - Option +max_nesting+, if not provided, defaults to +false+,
1001
+ # which disables checking for nesting depth.
1002
+ # - Option +allow_nan+, if not provided, defaults to +true+.
1003
+ #
1004
+ # source://json//lib/json/common.rb#373
1005
+ def parse!(source, opts = T.unsafe(nil)); end
1006
+
1007
+ # :call-seq:
1008
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
1009
+ #
1010
+ # Arguments +obj+ and +opts+ here are the same as
1011
+ # arguments +obj+ and +opts+ in JSON.generate.
1012
+ #
1013
+ # Default options are:
1014
+ # {
1015
+ # indent: ' ', # Two spaces
1016
+ # space: ' ', # One space
1017
+ # array_nl: "\n", # Newline
1018
+ # object_nl: "\n" # Newline
1019
+ # }
1020
+ #
1021
+ # Example:
1022
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
1023
+ # json = JSON.pretty_generate(obj)
1024
+ # puts json
1025
+ # Output:
1026
+ # {
1027
+ # "foo": [
1028
+ # "bar",
1029
+ # "baz"
1030
+ # ],
1031
+ # "bat": {
1032
+ # "bam": 0,
1033
+ # "bad": 1
1034
+ # }
1035
+ # }
1036
+ #
1037
+ # source://json//lib/json/common.rb#507
1038
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
1039
+
1040
+ # source://json//lib/json/common.rb#985
1041
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1042
+
1043
+ # source://json//lib/json/common.rb#995
1044
+ def restore(*_arg0, **_arg1, &_arg2); end
1045
+
1046
+ # :stopdoc:
1047
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1048
+ # so usage still exist in the wild.
1049
+ #
1050
+ # source://json//lib/json/common.rb#965
1051
+ def unparse(*_arg0, **_arg1, &_arg2); end
1052
+
1053
+ # :call-seq:
1054
+ # JSON.unsafe_load(source, options = {}) -> object
1055
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
1056
+ #
1057
+ # Returns the Ruby objects created by parsing the given +source+.
1058
+ #
1059
+ # BEWARE: This method is meant to serialise data from trusted user input,
1060
+ # like from your own database server or clients under your control, it could
1061
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1062
+ #
1063
+ # - Argument +source+ must be, or be convertible to, a \String:
1064
+ # - If +source+ responds to instance method +to_str+,
1065
+ # <tt>source.to_str</tt> becomes the source.
1066
+ # - If +source+ responds to instance method +to_io+,
1067
+ # <tt>source.to_io.read</tt> becomes the source.
1068
+ # - If +source+ responds to instance method +read+,
1069
+ # <tt>source.read</tt> becomes the source.
1070
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1071
+ # - Option +allow_blank+ specifies a truthy value.
1072
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1073
+ # - Otherwise, +source+ remains the source.
1074
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1075
+ # It will be called recursively with each result (depth-first order).
1076
+ # See details below.
1077
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1078
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1079
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1080
+ #
1081
+ # ---
1082
+ #
1083
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1084
+ # <tt>parse(source, opts)</tt>; see #parse.
1085
+ #
1086
+ # Source for following examples:
1087
+ # source = <<~JSON
1088
+ # {
1089
+ # "name": "Dave",
1090
+ # "age" :40,
1091
+ # "hats": [
1092
+ # "Cattleman's",
1093
+ # "Panama",
1094
+ # "Tophat"
1095
+ # ]
1096
+ # }
1097
+ # JSON
1098
+ #
1099
+ # Load a \String:
1100
+ # ruby = JSON.unsafe_load(source)
1101
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1102
+ #
1103
+ # Load an \IO object:
1104
+ # require 'stringio'
1105
+ # object = JSON.unsafe_load(StringIO.new(source))
1106
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1107
+ #
1108
+ # Load a \File object:
1109
+ # path = 't.json'
1110
+ # File.write(path, source)
1111
+ # File.open(path) do |file|
1112
+ # JSON.unsafe_load(file)
1113
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1114
+ #
1115
+ # ---
1116
+ #
1117
+ # When +proc+ is given:
1118
+ # - Modifies +source+ as above.
1119
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1120
+ # - Recursively calls <tt>proc(result)</tt>.
1121
+ # - Returns the final result.
1122
+ #
1123
+ # Example:
1124
+ # require 'json'
1125
+ #
1126
+ # # Some classes for the example.
1127
+ # class Base
1128
+ # def initialize(attributes)
1129
+ # @attributes = attributes
1130
+ # end
1131
+ # end
1132
+ # class User < Base; end
1133
+ # class Account < Base; end
1134
+ # class Admin < Base; end
1135
+ # # The JSON source.
1136
+ # json = <<-EOF
1137
+ # {
1138
+ # "users": [
1139
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1140
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1141
+ # ],
1142
+ # "accounts": [
1143
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1144
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1145
+ # ],
1146
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1147
+ # }
1148
+ # EOF
1149
+ # # Deserializer method.
1150
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1151
+ # type = obj.is_a?(Hash) && obj["type"]
1152
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1153
+ # end
1154
+ # # Call to JSON.unsafe_load
1155
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1156
+ # case obj
1157
+ # when Hash
1158
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1159
+ # when Array
1160
+ # obj.map! {|v| deserialize_obj v }
1161
+ # end
1162
+ # obj
1163
+ # })
1164
+ # pp ruby
1165
+ # Output:
1166
+ # {"users"=>
1167
+ # [#<User:0x00000000064c4c98
1168
+ # @attributes=
1169
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1170
+ # #<User:0x00000000064c4bd0
1171
+ # @attributes=
1172
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1173
+ # "accounts"=>
1174
+ # [{"account"=>
1175
+ # #<Account:0x00000000064c4928
1176
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1177
+ # {"account"=>
1178
+ # #<Account:0x00000000064c4680
1179
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1180
+ # "admins"=>
1181
+ # #<Admin:0x00000000064c41f8
1182
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1183
+ #
1184
+ # source://json//lib/json/common.rb#683
1185
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1186
+
1187
+ class << self
1188
+ # :call-seq:
1189
+ # JSON[object] -> new_array or new_string
1190
+ #
1191
+ # If +object+ is a \String,
1192
+ # calls JSON.parse with +object+ and +opts+ (see method #parse):
1193
+ # json = '[0, 1, null]'
1194
+ # JSON[json]# => [0, 1, nil]
1195
+ #
1196
+ # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
1197
+ # ruby = [0, 1, nil]
1198
+ # JSON[ruby] # => '[0,1,null]'
1199
+ #
1200
+ # source://json//lib/json/common.rb#132
1201
+ def [](object, opts = T.unsafe(nil)); end
1202
+
1203
+ # source://json//lib/json/common.rb#206
1204
+ def _dump_default_options; end
1205
+
1206
+ # source://json//lib/json/common.rb#206
1207
+ def _load_default_options; end
1208
+
1209
+ # source://json//lib/json/common.rb#206
1210
+ def _unsafe_load_default_options; end
1211
+
1212
+ # Returns the current create identifier.
1213
+ # See also JSON.create_id=.
1214
+ #
1215
+ # source://json//lib/json/common.rb#234
1216
+ def create_id; end
1217
+
1218
+ # Sets create identifier, which is used to decide if the _json_create_
1219
+ # hook of a class should be called; initial value is +json_class+:
1220
+ # JSON.create_id # => 'json_class'
1221
+ #
1222
+ # source://json//lib/json/common.rb#228
1223
+ def create_id=(new_value); end
1224
+
1225
+ # source://json//lib/json/common.rb#104
1226
+ def deprecation_warning(message, uplevel = T.unsafe(nil)); end
1227
+
1228
+ # :call-seq:
1229
+ # JSON.dump(obj, io = nil, limit = nil)
1230
+ #
1231
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
1232
+ #
1233
+ # The default options can be changed via method JSON.dump_default_options.
1234
+ #
1235
+ # - Argument +io+, if given, should respond to method +write+;
1236
+ # the \JSON \String is written to +io+, and +io+ is returned.
1237
+ # If +io+ is not given, the \JSON \String is returned.
1238
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
1239
+ #
1240
+ # ---
1241
+ #
1242
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
1243
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
1244
+ # json = JSON.dump(obj)
1245
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
1246
+ #
1247
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
1248
+ # path = 't.json'
1249
+ # File.open(path, 'w') do |file|
1250
+ # JSON.dump(obj, file)
1251
+ # end # => #<File:t.json (closed)>
1252
+ # puts File.read(path)
1253
+ # Output:
1254
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1255
+ #
1256
+ # source://json//lib/json/common.rb#930
1257
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1258
+
1259
+ # source://json//lib/json/common.rb#206
1260
+ def dump_default_options; end
1261
+
1262
+ # source://json//lib/json/common.rb#206
1263
+ def dump_default_options=(val); end
1264
+
1265
+ # :call-seq:
1266
+ # JSON.fast_generate(obj, opts) -> new_string
1267
+ #
1268
+ # Arguments +obj+ and +opts+ here are the same as
1269
+ # arguments +obj+ and +opts+ in JSON.generate.
1270
+ #
1271
+ # By default, generates \JSON data without checking
1272
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
1273
+ #
1274
+ # Raises an exception if +obj+ contains circular references:
1275
+ # a = []; b = []; a.push(b); b.push(a)
1276
+ # # Raises SystemStackError (stack level too deep):
1277
+ # JSON.fast_generate(a)
1278
+ #
1279
+ # source://json//lib/json/common.rb#460
1280
+ def fast_generate(obj, opts = T.unsafe(nil)); end
1281
+
1282
+ # source://json//lib/json/common.rb#975
1283
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
1284
+
1285
+ # :call-seq:
1286
+ # JSON.generate(obj, opts = nil) -> new_string
1287
+ #
1288
+ # Returns a \String containing the generated \JSON data.
1289
+ #
1290
+ # See also JSON.pretty_generate.
1291
+ #
1292
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
1293
+ #
1294
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1295
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
1296
+ #
1297
+ # ---
1298
+ #
1299
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
1300
+ # obj = ["foo", 1.0, true, false, nil]
1301
+ # json = JSON.generate(obj)
1302
+ # json # => '["foo",1.0,true,false,null]'
1303
+ #
1304
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
1305
+ # obj = {foo: 0, bar: 's', baz: :bat}
1306
+ # json = JSON.generate(obj)
1307
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
1308
+ #
1309
+ # For examples of generating from other Ruby objects, see
1310
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
1311
+ #
1312
+ # ---
1313
+ #
1314
+ # Raises an exception if any formatting option is not a \String.
1315
+ #
1316
+ # Raises an exception if +obj+ contains circular references:
1317
+ # a = []; b = []; a.push(b); b.push(a)
1318
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
1319
+ # JSON.generate(a)
1320
+ #
1321
+ # source://json//lib/json/common.rb#439
1322
+ def generate(obj, opts = T.unsafe(nil)); end
1323
+
1324
+ # Returns the JSON generator module that is used by JSON.
1325
+ #
1326
+ # source://json//lib/json/common.rb#177
1327
+ def generator; end
1328
+
1329
+ # Set the module _generator_ to be used by JSON.
1330
+ #
1331
+ # source://json//lib/json/common.rb#156
1332
+ def generator=(generator); end
1333
+
1334
+ # :call-seq:
1335
+ # JSON.load(source, options = {}) -> object
1336
+ # JSON.load(source, proc = nil, options = {}) -> object
1337
+ #
1338
+ # Returns the Ruby objects created by parsing the given +source+.
1339
+ #
1340
+ # BEWARE: This method is meant to serialise data from trusted user input,
1341
+ # like from your own database server or clients under your control, it could
1342
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1343
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
1344
+ #
1345
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
1346
+ # non native type is deserialized, without `create_additions` being explicitly
1347
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
1348
+ # by default.
1349
+ #
1350
+ # - Argument +source+ must be, or be convertible to, a \String:
1351
+ # - If +source+ responds to instance method +to_str+,
1352
+ # <tt>source.to_str</tt> becomes the source.
1353
+ # - If +source+ responds to instance method +to_io+,
1354
+ # <tt>source.to_io.read</tt> becomes the source.
1355
+ # - If +source+ responds to instance method +read+,
1356
+ # <tt>source.read</tt> becomes the source.
1357
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1358
+ # - Option +allow_blank+ specifies a truthy value.
1359
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1360
+ # - Otherwise, +source+ remains the source.
1361
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1362
+ # It will be called recursively with each result (depth-first order).
1363
+ # See details below.
1364
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1365
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1366
+ # The default options can be changed via method JSON.load_default_options=.
1367
+ #
1368
+ # ---
1369
+ #
1370
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1371
+ # <tt>parse(source, opts)</tt>; see #parse.
1372
+ #
1373
+ # Source for following examples:
1374
+ # source = <<~JSON
1375
+ # {
1376
+ # "name": "Dave",
1377
+ # "age" :40,
1378
+ # "hats": [
1379
+ # "Cattleman's",
1380
+ # "Panama",
1381
+ # "Tophat"
1382
+ # ]
1383
+ # }
1384
+ # JSON
1385
+ #
1386
+ # Load a \String:
1387
+ # ruby = JSON.load(source)
1388
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1389
+ #
1390
+ # Load an \IO object:
1391
+ # require 'stringio'
1392
+ # object = JSON.load(StringIO.new(source))
1393
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1394
+ #
1395
+ # Load a \File object:
1396
+ # path = 't.json'
1397
+ # File.write(path, source)
1398
+ # File.open(path) do |file|
1399
+ # JSON.load(file)
1400
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1401
+ #
1402
+ # ---
1403
+ #
1404
+ # When +proc+ is given:
1405
+ # - Modifies +source+ as above.
1406
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1407
+ # - Recursively calls <tt>proc(result)</tt>.
1408
+ # - Returns the final result.
1409
+ #
1410
+ # Example:
1411
+ # require 'json'
1412
+ #
1413
+ # # Some classes for the example.
1414
+ # class Base
1415
+ # def initialize(attributes)
1416
+ # @attributes = attributes
1417
+ # end
1418
+ # end
1419
+ # class User < Base; end
1420
+ # class Account < Base; end
1421
+ # class Admin < Base; end
1422
+ # # The JSON source.
1423
+ # json = <<-EOF
1424
+ # {
1425
+ # "users": [
1426
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1427
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1428
+ # ],
1429
+ # "accounts": [
1430
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1431
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1432
+ # ],
1433
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1434
+ # }
1435
+ # EOF
1436
+ # # Deserializer method.
1437
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1438
+ # type = obj.is_a?(Hash) && obj["type"]
1439
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1440
+ # end
1441
+ # # Call to JSON.load
1442
+ # ruby = JSON.load(json, proc {|obj|
1443
+ # case obj
1444
+ # when Hash
1445
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1446
+ # when Array
1447
+ # obj.map! {|v| deserialize_obj v }
1448
+ # end
1449
+ # obj
1450
+ # })
1451
+ # pp ruby
1452
+ # Output:
1453
+ # {"users"=>
1454
+ # [#<User:0x00000000064c4c98
1455
+ # @attributes=
1456
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1457
+ # #<User:0x00000000064c4bd0
1458
+ # @attributes=
1459
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1460
+ # "accounts"=>
1461
+ # [{"account"=>
1462
+ # #<Account:0x00000000064c4928
1463
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1464
+ # {"account"=>
1465
+ # #<Account:0x00000000064c4680
1466
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1467
+ # "admins"=>
1468
+ # #<Admin:0x00000000064c41f8
1469
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1470
+ #
1471
+ # source://json//lib/json/common.rb#854
1472
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1473
+
1474
+ # source://json//lib/json/common.rb#206
1475
+ def load_default_options; end
1476
+
1477
+ # source://json//lib/json/common.rb#206
1478
+ def load_default_options=(val); end
1479
+
1480
+ # :call-seq:
1481
+ # JSON.load_file(path, opts={}) -> object
1482
+ #
1483
+ # Calls:
1484
+ # parse(File.read(path), opts)
1485
+ #
1486
+ # See method #parse.
1487
+ #
1488
+ # source://json//lib/json/common.rb#388
1489
+ def load_file(filespec, opts = T.unsafe(nil)); end
1490
+
1491
+ # :call-seq:
1492
+ # JSON.load_file!(path, opts = {})
1493
+ #
1494
+ # Calls:
1495
+ # JSON.parse!(File.read(path, opts))
1496
+ #
1497
+ # See method #parse!
1498
+ #
1499
+ # source://json//lib/json/common.rb#399
1500
+ def load_file!(filespec, opts = T.unsafe(nil)); end
1501
+
1502
+ # :call-seq:
1503
+ # JSON.parse(source, opts) -> object
1504
+ #
1505
+ # Returns the Ruby objects created by parsing the given +source+.
1506
+ #
1507
+ # Argument +source+ contains the \String to be parsed.
1508
+ #
1509
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
1510
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1511
+ #
1512
+ # ---
1513
+ #
1514
+ # When +source+ is a \JSON array, returns a Ruby \Array:
1515
+ # source = '["foo", 1.0, true, false, null]'
1516
+ # ruby = JSON.parse(source)
1517
+ # ruby # => ["foo", 1.0, true, false, nil]
1518
+ # ruby.class # => Array
1519
+ #
1520
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
1521
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
1522
+ # ruby = JSON.parse(source)
1523
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
1524
+ # ruby.class # => Hash
1525
+ #
1526
+ # For examples of parsing for all \JSON data types, see
1527
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1528
+ #
1529
+ # Parses nested JSON objects:
1530
+ # source = <<~JSON
1531
+ # {
1532
+ # "name": "Dave",
1533
+ # "age" :40,
1534
+ # "hats": [
1535
+ # "Cattleman's",
1536
+ # "Panama",
1537
+ # "Tophat"
1538
+ # ]
1539
+ # }
1540
+ # JSON
1541
+ # ruby = JSON.parse(source)
1542
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1543
+ #
1544
+ # ---
1545
+ #
1546
+ # Raises an exception if +source+ is not valid JSON:
1547
+ # # Raises JSON::ParserError (783: unexpected token at ''):
1548
+ # JSON.parse('')
1549
+ #
1550
+ # source://json//lib/json/common.rb#351
1551
+ def parse(source, opts = T.unsafe(nil)); end
1552
+
1553
+ # :call-seq:
1554
+ # JSON.parse!(source, opts) -> object
1555
+ #
1556
+ # Calls
1557
+ # parse(source, opts)
1558
+ # with +source+ and possibly modified +opts+.
1559
+ #
1560
+ # Differences from JSON.parse:
1561
+ # - Option +max_nesting+, if not provided, defaults to +false+,
1562
+ # which disables checking for nesting depth.
1563
+ # - Option +allow_nan+, if not provided, defaults to +true+.
1564
+ #
1565
+ # source://json//lib/json/common.rb#373
1566
+ def parse!(source, opts = T.unsafe(nil)); end
1567
+
1568
+ # Returns the JSON parser class that is used by JSON.
1569
+ #
1570
+ # source://json//lib/json/common.rb#146
1571
+ def parser; end
1572
+
1573
+ # Set the JSON parser class _parser_ to be used by JSON.
1574
+ #
1575
+ # source://json//lib/json/common.rb#149
1576
+ def parser=(parser); end
1577
+
1578
+ # :call-seq:
1579
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
1580
+ #
1581
+ # Arguments +obj+ and +opts+ here are the same as
1582
+ # arguments +obj+ and +opts+ in JSON.generate.
1583
+ #
1584
+ # Default options are:
1585
+ # {
1586
+ # indent: ' ', # Two spaces
1587
+ # space: ' ', # One space
1588
+ # array_nl: "\n", # Newline
1589
+ # object_nl: "\n" # Newline
1590
+ # }
1591
+ #
1592
+ # Example:
1593
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
1594
+ # json = JSON.pretty_generate(obj)
1595
+ # puts json
1596
+ # Output:
1597
+ # {
1598
+ # "foo": [
1599
+ # "bar",
1600
+ # "baz"
1601
+ # ],
1602
+ # "bat": {
1603
+ # "bam": 0,
1604
+ # "bad": 1
1605
+ # }
1606
+ # }
1607
+ #
1608
+ # source://json//lib/json/common.rb#507
1609
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
1610
+
1611
+ # source://json//lib/json/common.rb#985
1612
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1613
+
1614
+ # source://json//lib/json/common.rb#995
1615
+ def restore(*_arg0, **_arg1, &_arg2); end
1616
+
1617
+ # Sets or Returns the JSON generator state class that is used by JSON.
1618
+ #
1619
+ # source://json//lib/json/common.rb#180
1620
+ def state; end
1621
+
1622
+ # Sets or Returns the JSON generator state class that is used by JSON.
1623
+ #
1624
+ # source://json//lib/json/common.rb#180
1625
+ def state=(_arg0); end
1626
+
1627
+ # :stopdoc:
1628
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1629
+ # so usage still exist in the wild.
1630
+ #
1631
+ # source://json//lib/json/common.rb#965
1632
+ def unparse(*_arg0, **_arg1, &_arg2); end
1633
+
1634
+ # :call-seq:
1635
+ # JSON.unsafe_load(source, options = {}) -> object
1636
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
1637
+ #
1638
+ # Returns the Ruby objects created by parsing the given +source+.
1639
+ #
1640
+ # BEWARE: This method is meant to serialise data from trusted user input,
1641
+ # like from your own database server or clients under your control, it could
1642
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1643
+ #
1644
+ # - Argument +source+ must be, or be convertible to, a \String:
1645
+ # - If +source+ responds to instance method +to_str+,
1646
+ # <tt>source.to_str</tt> becomes the source.
1647
+ # - If +source+ responds to instance method +to_io+,
1648
+ # <tt>source.to_io.read</tt> becomes the source.
1649
+ # - If +source+ responds to instance method +read+,
1650
+ # <tt>source.read</tt> becomes the source.
1651
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1652
+ # - Option +allow_blank+ specifies a truthy value.
1653
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1654
+ # - Otherwise, +source+ remains the source.
1655
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1656
+ # It will be called recursively with each result (depth-first order).
1657
+ # See details below.
1658
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1659
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1660
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1661
+ #
1662
+ # ---
1663
+ #
1664
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1665
+ # <tt>parse(source, opts)</tt>; see #parse.
1666
+ #
1667
+ # Source for following examples:
1668
+ # source = <<~JSON
1669
+ # {
1670
+ # "name": "Dave",
1671
+ # "age" :40,
1672
+ # "hats": [
1673
+ # "Cattleman's",
1674
+ # "Panama",
1675
+ # "Tophat"
1676
+ # ]
1677
+ # }
1678
+ # JSON
1679
+ #
1680
+ # Load a \String:
1681
+ # ruby = JSON.unsafe_load(source)
1682
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1683
+ #
1684
+ # Load an \IO object:
1685
+ # require 'stringio'
1686
+ # object = JSON.unsafe_load(StringIO.new(source))
1687
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1688
+ #
1689
+ # Load a \File object:
1690
+ # path = 't.json'
1691
+ # File.write(path, source)
1692
+ # File.open(path) do |file|
1693
+ # JSON.unsafe_load(file)
1694
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1695
+ #
1696
+ # ---
1697
+ #
1698
+ # When +proc+ is given:
1699
+ # - Modifies +source+ as above.
1700
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1701
+ # - Recursively calls <tt>proc(result)</tt>.
1702
+ # - Returns the final result.
1703
+ #
1704
+ # Example:
1705
+ # require 'json'
1706
+ #
1707
+ # # Some classes for the example.
1708
+ # class Base
1709
+ # def initialize(attributes)
1710
+ # @attributes = attributes
1711
+ # end
1712
+ # end
1713
+ # class User < Base; end
1714
+ # class Account < Base; end
1715
+ # class Admin < Base; end
1716
+ # # The JSON source.
1717
+ # json = <<-EOF
1718
+ # {
1719
+ # "users": [
1720
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1721
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1722
+ # ],
1723
+ # "accounts": [
1724
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1725
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1726
+ # ],
1727
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1728
+ # }
1729
+ # EOF
1730
+ # # Deserializer method.
1731
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1732
+ # type = obj.is_a?(Hash) && obj["type"]
1733
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1734
+ # end
1735
+ # # Call to JSON.unsafe_load
1736
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1737
+ # case obj
1738
+ # when Hash
1739
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1740
+ # when Array
1741
+ # obj.map! {|v| deserialize_obj v }
1742
+ # end
1743
+ # obj
1744
+ # })
1745
+ # pp ruby
1746
+ # Output:
1747
+ # {"users"=>
1748
+ # [#<User:0x00000000064c4c98
1749
+ # @attributes=
1750
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1751
+ # #<User:0x00000000064c4bd0
1752
+ # @attributes=
1753
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1754
+ # "accounts"=>
1755
+ # [{"account"=>
1756
+ # #<Account:0x00000000064c4928
1757
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1758
+ # {"account"=>
1759
+ # #<Account:0x00000000064c4680
1760
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1761
+ # "admins"=>
1762
+ # #<Admin:0x00000000064c41f8
1763
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1764
+ #
1765
+ # source://json//lib/json/common.rb#683
1766
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1767
+
1768
+ # source://json//lib/json/common.rb#206
1769
+ def unsafe_load_default_options; end
1770
+
1771
+ # source://json//lib/json/common.rb#206
1772
+ def unsafe_load_default_options=(val); end
1773
+
1774
+ private
1775
+
1776
+ # source://json//lib/json/common.rb#1008
1777
+ def const_missing(const_name); end
1778
+
1779
+ # source://json//lib/json/common.rb#203
1780
+ def deprecated_singleton_attr_accessor(*attrs); end
1781
+
1782
+ # Called from the extension when a hash has both string and symbol keys
1783
+ #
1784
+ # source://json//lib/json/common.rb#185
1785
+ def on_mixed_keys_hash(hash, do_raise); end
1786
+ end
1787
+ end
1788
+
1789
+ # JSON::Coder holds a parser and generator configuration.
1790
+ #
1791
+ # module MyApp
1792
+ # JSONC_CODER = JSON::Coder.new(
1793
+ # allow_trailing_comma: true
1794
+ # )
1795
+ # end
1796
+ #
1797
+ # MyApp::JSONC_CODER.load(document)
1798
+ #
1799
+ # source://json//lib/json/common.rb#1034
1800
+ class JSON::Coder
1801
+ # :call-seq:
1802
+ # JSON.new(options = nil, &block)
1803
+ #
1804
+ # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
1805
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options].
1806
+ #
1807
+ # For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
1808
+ # encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
1809
+ # \JSON counterpart:
1810
+ #
1811
+ # module MyApp
1812
+ # API_JSON_CODER = JSON::Coder.new do |object|
1813
+ # case object
1814
+ # when Time
1815
+ # object.iso8601(3)
1816
+ # else
1817
+ # object # Unknown type, will raise
1818
+ # end
1819
+ # end
1820
+ # end
1821
+ #
1822
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
1823
+ #
1824
+ # @return [Coder] a new instance of Coder
1825
+ #
1826
+ # source://json//lib/json/common.rb#1058
1827
+ def initialize(options = T.unsafe(nil), &as_json); end
1828
+
1829
+ # call-seq:
1830
+ # dump(object) -> String
1831
+ # dump(object, io) -> io
1832
+ #
1833
+ # Serialize the given object into a \JSON document.
1834
+ #
1835
+ # source://json//lib/json/common.rb#1076
1836
+ def dump(object, io = T.unsafe(nil)); end
1837
+
1838
+ # call-seq:
1839
+ # dump(object) -> String
1840
+ # dump(object, io) -> io
1841
+ #
1842
+ # Serialize the given object into a \JSON document.
1843
+ #
1844
+ # source://json//lib/json/common.rb#1079
1845
+ def generate(object, io = T.unsafe(nil)); end
1846
+
1847
+ # call-seq:
1848
+ # load(string) -> Object
1849
+ #
1850
+ # Parse the given \JSON document and return an equivalent Ruby object.
1851
+ #
1852
+ # source://json//lib/json/common.rb#1085
1853
+ def load(source); end
1854
+
1855
+ # call-seq:
1856
+ # load(path) -> Object
1857
+ #
1858
+ # Parse the given \JSON document and return an equivalent Ruby object.
1859
+ #
1860
+ # source://json//lib/json/common.rb#1094
1861
+ def load_file(path); end
1862
+
1863
+ # call-seq:
1864
+ # load(string) -> Object
1865
+ #
1866
+ # Parse the given \JSON document and return an equivalent Ruby object.
1867
+ #
1868
+ # source://json//lib/json/common.rb#1088
1869
+ def parse(source); end
1870
+ end
1871
+
1872
+ module JSON::Ext::Generator::GeneratorMethods::Array
1873
+ # source://json//lib/json/ext.rb#39
1874
+ def to_json(*_arg0); end
1875
+ end
1876
+
1877
+ module JSON::Ext::Generator::GeneratorMethods::FalseClass
1878
+ # source://json//lib/json/ext.rb#39
1879
+ def to_json(*_arg0); end
1880
+ end
1881
+
1882
+ module JSON::Ext::Generator::GeneratorMethods::Float
1883
+ # source://json//lib/json/ext.rb#39
1884
+ def to_json(*_arg0); end
1885
+ end
1886
+
1887
+ module JSON::Ext::Generator::GeneratorMethods::Hash
1888
+ # source://json//lib/json/ext.rb#39
1889
+ def to_json(*_arg0); end
1890
+ end
1891
+
1892
+ module JSON::Ext::Generator::GeneratorMethods::Integer
1893
+ # source://json//lib/json/ext.rb#39
1894
+ def to_json(*_arg0); end
1895
+ end
1896
+
1897
+ module JSON::Ext::Generator::GeneratorMethods::NilClass
1898
+ # source://json//lib/json/ext.rb#39
1899
+ def to_json(*_arg0); end
1900
+ end
1901
+
1902
+ module JSON::Ext::Generator::GeneratorMethods::Object
1903
+ # source://json//lib/json/ext.rb#39
1904
+ def to_json(*_arg0); end
1905
+ end
1906
+
1907
+ module JSON::Ext::Generator::GeneratorMethods::String
1908
+ # source://json//lib/json/ext.rb#39
1909
+ def to_json(*_arg0); end
1910
+ end
1911
+
1912
+ module JSON::Ext::Generator::GeneratorMethods::TrueClass
1913
+ # source://json//lib/json/ext.rb#39
1914
+ def to_json(*_arg0); end
1915
+ end
1916
+
1917
+ # source://json//lib/json/ext/generator/state.rb#6
1918
+ class JSON::Ext::Generator::State
1919
+ # call-seq: new(opts = {})
1920
+ #
1921
+ # Instantiates a new State object, configured by _opts_.
1922
+ #
1923
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1924
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
1925
+ #
1926
+ # @return [State] a new instance of State
1927
+ #
1928
+ # source://json//lib/json/ext.rb#39
1929
+ def initialize(opts = T.unsafe(nil)); end
1930
+
1931
+ # call-seq: [](name)
1932
+ #
1933
+ # Returns the value returned by method +name+.
1934
+ #
1935
+ # source://json//lib/json/ext/generator/state.rb#77
1936
+ def [](name); end
1937
+
1938
+ # call-seq: []=(name, value)
1939
+ #
1940
+ # Sets the attribute name to value.
1941
+ #
1942
+ # source://json//lib/json/ext/generator/state.rb#91
1943
+ def []=(name, value); end
1944
+
1945
+ # source://json//lib/json/ext.rb#39
1946
+ def allow_nan=(_arg0); end
1947
+
1948
+ # source://json//lib/json/ext.rb#39
1949
+ def allow_nan?; end
1950
+
1951
+ # source://json//lib/json/ext.rb#39
1952
+ def array_nl; end
1953
+
1954
+ # source://json//lib/json/ext.rb#39
1955
+ def array_nl=(_arg0); end
1956
+
1957
+ # source://json//lib/json/ext.rb#39
1958
+ def as_json; end
1959
+
1960
+ # source://json//lib/json/ext.rb#39
1961
+ def as_json=(_arg0); end
1962
+
1963
+ # source://json//lib/json/ext.rb#39
1964
+ def ascii_only=(_arg0); end
1965
+
1966
+ # source://json//lib/json/ext.rb#39
1967
+ def ascii_only?; end
1968
+
1969
+ # source://json//lib/json/ext.rb#39
1970
+ def buffer_initial_length; end
1971
+
1972
+ # source://json//lib/json/ext.rb#39
1973
+ def buffer_initial_length=(_arg0); end
1974
+
1975
+ # source://json//lib/json/ext.rb#39
1976
+ def check_circular?; end
1977
+
1978
+ # call-seq: configure(opts)
1979
+ #
1980
+ # Configure this State instance with the Hash _opts_, and return
1981
+ # itself.
1982
+ #
1983
+ # source://json//lib/json/ext/generator/state.rb#23
1984
+ def configure(opts); end
1985
+
1986
+ # source://json//lib/json/ext.rb#39
1987
+ def depth; end
1988
+
1989
+ # source://json//lib/json/ext.rb#39
1990
+ def depth=(_arg0); end
1991
+
1992
+ # source://json//lib/json/ext.rb#39
1993
+ def escape_slash; end
1994
+
1995
+ # source://json//lib/json/ext.rb#39
1996
+ def escape_slash=(_arg0); end
1997
+
1998
+ # source://json//lib/json/ext.rb#39
1999
+ def escape_slash?; end
2000
+
2001
+ # source://json//lib/json/ext.rb#39
2002
+ def generate(*_arg0); end
2003
+
2004
+ # source://json//lib/json/ext.rb#39
2005
+ def indent; end
2006
+
2007
+ # source://json//lib/json/ext.rb#39
2008
+ def indent=(_arg0); end
2009
+
2010
+ # source://json//lib/json/ext.rb#39
2011
+ def max_nesting; end
2012
+
2013
+ # source://json//lib/json/ext.rb#39
2014
+ def max_nesting=(_arg0); end
2015
+
2016
+ # call-seq: configure(opts)
2017
+ #
2018
+ # Configure this State instance with the Hash _opts_, and return
2019
+ # itself.
2020
+ #
2021
+ # source://json//lib/json/ext/generator/state.rb#36
2022
+ def merge(opts); end
2023
+
2024
+ # source://json//lib/json/ext.rb#39
2025
+ def object_nl; end
2026
+
2027
+ # source://json//lib/json/ext.rb#39
2028
+ def object_nl=(_arg0); end
2029
+
2030
+ # source://json//lib/json/ext.rb#39
2031
+ def script_safe; end
2032
+
2033
+ # source://json//lib/json/ext.rb#39
2034
+ def script_safe=(_arg0); end
2035
+
2036
+ # source://json//lib/json/ext.rb#39
2037
+ def script_safe?; end
2038
+
2039
+ # source://json//lib/json/ext.rb#39
2040
+ def space; end
2041
+
2042
+ # source://json//lib/json/ext.rb#39
2043
+ def space=(_arg0); end
2044
+
2045
+ # source://json//lib/json/ext.rb#39
2046
+ def space_before; end
2047
+
2048
+ # source://json//lib/json/ext.rb#39
2049
+ def space_before=(_arg0); end
2050
+
2051
+ # source://json//lib/json/ext.rb#39
2052
+ def strict; end
2053
+
2054
+ # source://json//lib/json/ext.rb#39
2055
+ def strict=(_arg0); end
2056
+
2057
+ # source://json//lib/json/ext.rb#39
2058
+ def strict?; end
2059
+
2060
+ # call-seq: to_h
2061
+ #
2062
+ # Returns the configuration instance variables as a hash, that can be
2063
+ # passed to the configure method.
2064
+ #
2065
+ # source://json//lib/json/ext/generator/state.rb#42
2066
+ def to_h; end
2067
+
2068
+ # call-seq: to_h
2069
+ #
2070
+ # Returns the configuration instance variables as a hash, that can be
2071
+ # passed to the configure method.
2072
+ #
2073
+ # source://json//lib/json/ext/generator/state.rb#72
2074
+ def to_hash; end
2075
+
2076
+ private
2077
+
2078
+ # source://json//lib/json/ext.rb#39
2079
+ def _configure(_arg0); end
2080
+
2081
+ # source://json//lib/json/ext.rb#39
2082
+ def allow_duplicate_key?; end
2083
+
2084
+ # source://json//lib/json/ext.rb#39
2085
+ def initialize_copy(_arg0); end
2086
+
2087
+ class << self
2088
+ # source://json//lib/json/ext.rb#39
2089
+ def from_state(_arg0); end
2090
+
2091
+ # source://json//lib/json/ext.rb#39
2092
+ def generate(_arg0, _arg1, _arg2); end
2093
+ end
2094
+ end
2095
+
2096
+ # source://json//lib/json/ext.rb#9
2097
+ class JSON::Ext::Parser
2098
+ # @return [Parser] a new instance of Parser
2099
+ #
2100
+ # source://json//lib/json/ext.rb#17
2101
+ def initialize(source, opts = T.unsafe(nil)); end
2102
+
2103
+ # source://json//lib/json/ext.rb#26
2104
+ def parse; end
2105
+
2106
+ # source://json//lib/json/ext.rb#22
2107
+ def source; end
2108
+
2109
+ class << self
2110
+ # Allow redefinition by extensions
2111
+ # Allow redefinition by extensions
2112
+ #
2113
+ # source://json//lib/json/ext.rb#11
2114
+ def parse(_arg0, _arg1); end
2115
+ end
2116
+ end
2117
+
2118
+ # source://json//lib/json/ext.rb#32
2119
+ JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
2120
+
2121
+ class JSON::Ext::ParserConfig
2122
+ # source://json//lib/json/ext.rb#31
2123
+ def initialize(_arg0); end
2124
+
2125
+ # source://json//lib/json/ext.rb#31
2126
+ def parse(_arg0); end
2127
+ end
2128
+
2129
+ # Fragment of JSON document that is to be included as is:
2130
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
2131
+ # JSON.generate({ count: 3, items: fragments })
2132
+ #
2133
+ # This allows to easily assemble multiple JSON fragments that have
2134
+ # been persisted somewhere without having to parse them nor resorting
2135
+ # to string interpolation.
2136
+ #
2137
+ # Note: no validation is performed on the provided string. It is the
2138
+ # responsibility of the caller to ensure the string contains valid JSON.
2139
+ #
2140
+ # source://json//lib/json/common.rb#287
2141
+ class JSON::Fragment < ::Struct
2142
+ # @return [Fragment] a new instance of Fragment
2143
+ #
2144
+ # source://json//lib/json/common.rb#288
2145
+ def initialize(json); end
2146
+
2147
+ # Returns the value of attribute json
2148
+ #
2149
+ # @return [Object] the current value of json
2150
+ #
2151
+ # source://json//lib/json/common.rb#287
2152
+ def json; end
2153
+
2154
+ # Sets the attribute json
2155
+ #
2156
+ # @param value [Object] the value to set the attribute json to.
2157
+ # @return [Object] the newly set value
2158
+ #
2159
+ # source://json//lib/json/common.rb#287
2160
+ def json=(_); end
2161
+
2162
+ # source://json//lib/json/common.rb#296
2163
+ def to_json(state = T.unsafe(nil), *_arg1); end
2164
+
2165
+ class << self
2166
+ # source://json//lib/json/common.rb#287
2167
+ def [](*_arg0); end
2168
+
2169
+ # source://json//lib/json/common.rb#287
2170
+ def inspect; end
2171
+
2172
+ # source://json//lib/json/common.rb#287
2173
+ def keyword_init?; end
2174
+
2175
+ # source://json//lib/json/common.rb#287
2176
+ def members; end
2177
+
2178
+ # source://json//lib/json/common.rb#287
2179
+ def new(*_arg0); end
2180
+ end
2181
+ end
2182
+
2183
+ # This exception is raised if a generator or unparser error occurs.
2184
+ #
2185
+ # source://json//lib/json/common.rb#257
2186
+ class JSON::GeneratorError < ::JSON::JSONError
2187
+ # @return [GeneratorError] a new instance of GeneratorError
2188
+ #
2189
+ # source://json//lib/json/common.rb#260
2190
+ def initialize(message, invalid_object = T.unsafe(nil)); end
2191
+
2192
+ # source://json//lib/json/common.rb#265
2193
+ def detailed_message(*_arg0, **_arg1, &_arg2); end
2194
+
2195
+ # Returns the value of attribute invalid_object.
2196
+ #
2197
+ # source://json//lib/json/common.rb#258
2198
+ def invalid_object; end
2199
+ end
2200
+
2201
+ # source://json//lib/json/generic_object.rb#9
2202
+ class JSON::GenericObject < ::OpenStruct
2203
+ # source://json//lib/json/generic_object.rb#59
2204
+ def as_json(*_arg0); end
2205
+
2206
+ # source://json//lib/json/generic_object.rb#51
2207
+ def to_hash; end
2208
+
2209
+ # source://json//lib/json/generic_object.rb#63
2210
+ def to_json(*a); end
2211
+
2212
+ # source://json//lib/json/generic_object.rb#55
2213
+ def |(other); end
2214
+
2215
+ class << self
2216
+ # source://json//lib/json/generic_object.rb#11
2217
+ def [](*_arg0); end
2218
+
2219
+ # source://json//lib/json/generic_object.rb#45
2220
+ def dump(obj, *args); end
2221
+
2222
+ # source://json//lib/json/generic_object.rb#25
2223
+ def from_hash(object); end
2224
+
2225
+ # Sets the attribute json_creatable
2226
+ #
2227
+ # @param value the value to set the attribute json_creatable to.
2228
+ #
2229
+ # source://json//lib/json/generic_object.rb#17
2230
+ def json_creatable=(_arg0); end
2231
+
2232
+ # @return [Boolean]
2233
+ #
2234
+ # source://json//lib/json/generic_object.rb#13
2235
+ def json_creatable?; end
2236
+
2237
+ # source://json//lib/json/generic_object.rb#19
2238
+ def json_create(data); end
2239
+
2240
+ # source://json//lib/json/generic_object.rb#40
2241
+ def load(source, proc = T.unsafe(nil), opts = T.unsafe(nil)); end
2242
+ end
2243
+ end
2244
+
2245
+ # source://json//lib/json/common.rb#356
2246
+ JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
2247
+
2248
+ # source://json//lib/json/common.rb#469
2249
+ JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
2250
+
2251
+ # source://json//lib/json/common.rb#152
2252
+ JSON::Parser = JSON::Ext::Parser
2253
+
2254
+ # This exception is raised if a parser error occurs.
2255
+ #
2256
+ # source://json//lib/json/common.rb#248
2257
+ class JSON::ParserError < ::JSON::JSONError
2258
+ # Returns the value of attribute column.
2259
+ #
2260
+ # source://json//lib/json/common.rb#249
2261
+ def column; end
2262
+
2263
+ # Returns the value of attribute line.
2264
+ #
2265
+ # source://json//lib/json/common.rb#249
2266
+ def line; end
2267
+ end
2268
+
2269
+ # source://json//lib/json/common.rb#8
2270
+ module JSON::ParserOptions
2271
+ class << self
2272
+ # source://json//lib/json/common.rb#10
2273
+ def prepare(opts); end
2274
+
2275
+ private
2276
+
2277
+ # source://json//lib/json/common.rb#40
2278
+ def array_class_proc(array_class, on_load); end
2279
+
2280
+ # TODO: extract :create_additions support to another gem for version 3.0
2281
+ #
2282
+ # source://json//lib/json/common.rb#52
2283
+ def create_additions_proc(opts); end
2284
+
2285
+ # source://json//lib/json/common.rb#95
2286
+ def create_additions_warning; end
2287
+
2288
+ # source://json//lib/json/common.rb#29
2289
+ def object_class_proc(object_class, on_load); end
2290
+ end
2291
+ end
2292
+
2293
+ # source://json//lib/json/common.rb#171
2294
+ JSON::State = JSON::Ext::Generator::State
2295
+
2296
+ # source://json//lib/json/common.rb#1100
2297
+ module Kernel
2298
+ private
2299
+
2300
+ # If _object_ is string-like, parse the string and return the parsed result as
2301
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
2302
+ # structure object and return it.
2303
+ #
2304
+ # The _opts_ argument is passed through to generate/parse respectively. See
2305
+ # generate and parse for their documentation.
2306
+ #
2307
+ # source://json//lib/json/common.rb#1139
2308
+ def JSON(object, opts = T.unsafe(nil)); end
2309
+
2310
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
2311
+ # one line.
2312
+ #
2313
+ # source://json//lib/json/common.rb#1105
2314
+ def j(*objs); end
2315
+
2316
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
2317
+ # indentation and over many lines.
2318
+ #
2319
+ # source://json//lib/json/common.rb#1120
2320
+ def jj(*objs); end
2321
+ end
2322
+
2323
+ class NilClass
2324
+ include ::JSON::Ext::Generator::GeneratorMethods::NilClass
2325
+ end
2326
+
2327
+ class Object < ::BasicObject
2328
+ include ::Kernel
2329
+ include ::PP::ObjectMixin
2330
+ include ::JSON::Ext::Generator::GeneratorMethods::Object
2331
+ end
2332
+
2333
+ class String
2334
+ include ::Comparable
2335
+ include ::JSON::Ext::Generator::GeneratorMethods::String
2336
+ end
2337
+
2338
+ class TrueClass
2339
+ include ::JSON::Ext::Generator::GeneratorMethods::TrueClass
2340
+ end