ori-rb 0.4

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