redis-promise 0.1.0

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