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