deck_of_cards_handler 0.1.1 → 0.1.2

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