esquema 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/CHANGELOG.md +9 -1
  4. data/README.md +11 -9
  5. data/lib/esquema/builder.rb +73 -28
  6. data/lib/esquema/configuration.rb +2 -1
  7. data/lib/esquema/keyword_validator.rb +98 -0
  8. data/lib/esquema/model.rb +4 -0
  9. data/lib/esquema/property.rb +185 -26
  10. data/lib/esquema/schema_enhancer.rb +55 -30
  11. data/lib/esquema/type_caster.rb +16 -4
  12. data/lib/esquema/version.rb +1 -1
  13. data/lib/esquema/virtual_column.rb +46 -0
  14. data/lib/esquema.rb +7 -1
  15. data/lib/generators/esquema/install/install_generator.rb +1 -0
  16. data/sorbet/config +4 -0
  17. data/sorbet/rbi/annotations/.gitattributes +1 -0
  18. data/sorbet/rbi/annotations/activemodel.rbi +89 -0
  19. data/sorbet/rbi/annotations/activerecord.rbi +92 -0
  20. data/sorbet/rbi/annotations/activesupport.rbi +421 -0
  21. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  22. data/sorbet/rbi/gems/.gitattributes +1 -0
  23. data/sorbet/rbi/gems/activemodel@7.1.3.rbi +8 -0
  24. data/sorbet/rbi/gems/activerecord@7.1.3.rbi +8 -0
  25. data/sorbet/rbi/gems/activesupport@7.1.3.rbi +192 -0
  26. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  27. data/sorbet/rbi/gems/base64@0.2.0.rbi +8 -0
  28. data/sorbet/rbi/gems/bigdecimal@3.1.6.rbi +8 -0
  29. data/sorbet/rbi/gems/byebug@11.1.3.rbi +3606 -0
  30. data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
  31. data/sorbet/rbi/gems/concurrent-ruby@1.2.3.rbi +8 -0
  32. data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +8 -0
  33. data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1130 -0
  34. data/sorbet/rbi/gems/drb@2.2.0.rbi +1272 -0
  35. data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
  36. data/sorbet/rbi/gems/i18n@1.14.1.rbi +8 -0
  37. data/sorbet/rbi/gems/json@2.7.1.rbi +1553 -0
  38. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
  39. data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
  40. data/sorbet/rbi/gems/minitest@5.22.2.rbi +8 -0
  41. data/sorbet/rbi/gems/mutex_m@0.2.0.rbi +8 -0
  42. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  43. data/sorbet/rbi/gems/parallel@1.24.0.rbi +280 -0
  44. data/sorbet/rbi/gems/parser@3.3.0.5.rbi +5472 -0
  45. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
  46. data/sorbet/rbi/gems/prism@0.24.0.rbi +31040 -0
  47. data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +1150 -0
  48. data/sorbet/rbi/gems/pry@0.14.2.rbi +10075 -0
  49. data/sorbet/rbi/gems/racc@1.7.3.rbi +157 -0
  50. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
  51. data/sorbet/rbi/gems/rake@13.1.0.rbi +3027 -0
  52. data/sorbet/rbi/gems/rbi@0.1.9.rbi +3006 -0
  53. data/sorbet/rbi/gems/regexp_parser@2.9.0.rbi +3771 -0
  54. data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
  55. data/sorbet/rbi/gems/rspec-core@3.13.0.rbi +10978 -0
  56. data/sorbet/rbi/gems/rspec-expectations@3.13.0.rbi +8153 -0
  57. data/sorbet/rbi/gems/rspec-mocks@3.13.0.rbi +5340 -0
  58. data/sorbet/rbi/gems/rspec-support@3.13.0.rbi +1629 -0
  59. data/sorbet/rbi/gems/rspec@3.13.0.rbi +82 -0
  60. data/sorbet/rbi/gems/rubocop-ast@1.30.0.rbi +7006 -0
  61. data/sorbet/rbi/gems/rubocop@1.60.2.rbi +57383 -0
  62. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
  63. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
  64. data/sorbet/rbi/gems/spoom@1.2.4.rbi +3777 -0
  65. data/sorbet/rbi/gems/sqlite3@1.7.2.rbi +1691 -0
  66. data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +23133 -0
  67. data/sorbet/rbi/gems/tapioca@0.12.0.rbi +3510 -0
  68. data/sorbet/rbi/gems/thor@1.3.0.rbi +4345 -0
  69. data/sorbet/rbi/gems/timeout@0.4.1.rbi +142 -0
  70. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +8 -0
  71. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +65 -0
  72. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
  73. data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
  74. data/sorbet/rbi/todo.rbi +20 -0
  75. data/sorbet/tapioca/config.yml +13 -0
  76. data/sorbet/tapioca/require.rb +4 -0
  77. metadata +74 -12
  78. data/esquema.gemspec +0 -38
@@ -0,0 +1,1553 @@
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
+ # Extends any Class to include _json_creatable?_ method.
8
+ class Class < ::Module
9
+ # Returns true if this class can be used to create an instance
10
+ # from a serialised JSON string. The class has to implement a class
11
+ # method _json_create_ that expects a hash as first parameter. The hash
12
+ # should include the required data.
13
+ #
14
+ # @return [Boolean]
15
+ #
16
+ # source://json//json/common.rb#694
17
+ def json_creatable?; end
18
+ end
19
+
20
+ # = JavaScript \Object Notation (\JSON)
21
+ #
22
+ # \JSON is a lightweight data-interchange format.
23
+ #
24
+ # A \JSON value is one of the following:
25
+ # - Double-quoted text: <tt>"foo"</tt>.
26
+ # - Number: +1+, +1.0+, +2.0e2+.
27
+ # - Boolean: +true+, +false+.
28
+ # - Null: +null+.
29
+ # - \Array: an ordered list of values, enclosed by square brackets:
30
+ # ["foo", 1, 1.0, 2.0e2, true, false, null]
31
+ #
32
+ # - \Object: a collection of name/value pairs, enclosed by curly braces;
33
+ # each name is double-quoted text;
34
+ # the values may be any \JSON values:
35
+ # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
36
+ #
37
+ # A \JSON array or object may contain nested arrays, objects, and scalars
38
+ # to any depth:
39
+ # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
40
+ # [{"foo": 0, "bar": 1}, ["baz", 2]]
41
+ #
42
+ # == Using \Module \JSON
43
+ #
44
+ # To make module \JSON available in your code, begin with:
45
+ # require 'json'
46
+ #
47
+ # All examples here assume that this has been done.
48
+ #
49
+ # === Parsing \JSON
50
+ #
51
+ # You can parse a \String containing \JSON data using
52
+ # either of two methods:
53
+ # - <tt>JSON.parse(source, opts)</tt>
54
+ # - <tt>JSON.parse!(source, opts)</tt>
55
+ #
56
+ # where
57
+ # - +source+ is a Ruby object.
58
+ # - +opts+ is a \Hash object containing options
59
+ # that control both input allowed and output formatting.
60
+ #
61
+ # The difference between the two methods
62
+ # is that JSON.parse! omits some checks
63
+ # and may not be safe for some +source+ data;
64
+ # use it only for data from trusted sources.
65
+ # Use the safer method JSON.parse for less trusted sources.
66
+ #
67
+ # ==== Parsing \JSON Arrays
68
+ #
69
+ # When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:
70
+ # json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
71
+ # ruby = JSON.parse(json)
72
+ # ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
73
+ # ruby.class # => Array
74
+ #
75
+ # The \JSON array may contain nested arrays, objects, and scalars
76
+ # to any depth:
77
+ # json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
78
+ # JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
79
+ #
80
+ # ==== Parsing \JSON \Objects
81
+ #
82
+ # When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:
83
+ # json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
84
+ # ruby = JSON.parse(json)
85
+ # ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
86
+ # ruby.class # => Hash
87
+ #
88
+ # The \JSON object may contain nested arrays, objects, and scalars
89
+ # to any depth:
90
+ # json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
91
+ # JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
92
+ #
93
+ # ==== Parsing \JSON Scalars
94
+ #
95
+ # When the source is a \JSON scalar (not an array or object),
96
+ # JSON.parse returns a Ruby scalar.
97
+ #
98
+ # \String:
99
+ # ruby = JSON.parse('"foo"')
100
+ # ruby # => 'foo'
101
+ # ruby.class # => String
102
+ # \Integer:
103
+ # ruby = JSON.parse('1')
104
+ # ruby # => 1
105
+ # ruby.class # => Integer
106
+ # \Float:
107
+ # ruby = JSON.parse('1.0')
108
+ # ruby # => 1.0
109
+ # ruby.class # => Float
110
+ # ruby = JSON.parse('2.0e2')
111
+ # ruby # => 200
112
+ # ruby.class # => Float
113
+ # Boolean:
114
+ # ruby = JSON.parse('true')
115
+ # ruby # => true
116
+ # ruby.class # => TrueClass
117
+ # ruby = JSON.parse('false')
118
+ # ruby # => false
119
+ # ruby.class # => FalseClass
120
+ # Null:
121
+ # ruby = JSON.parse('null')
122
+ # ruby # => nil
123
+ # ruby.class # => NilClass
124
+ #
125
+ # ==== Parsing Options
126
+ #
127
+ # ====== Input Options
128
+ #
129
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed;
130
+ # defaults to +100+; specify +false+ to disable depth checking.
131
+ #
132
+ # With the default, +false+:
133
+ # source = '[0, [1, [2, [3]]]]'
134
+ # ruby = JSON.parse(source)
135
+ # ruby # => [0, [1, [2, [3]]]]
136
+ # Too deep:
137
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
138
+ # JSON.parse(source, {max_nesting: 1})
139
+ # Bad value:
140
+ # # Raises TypeError (wrong argument type Symbol (expected Fixnum)):
141
+ # JSON.parse(source, {max_nesting: :foo})
142
+ #
143
+ # ---
144
+ #
145
+ # Option +allow_nan+ (boolean) specifies whether to allow
146
+ # NaN, Infinity, and MinusInfinity in +source+;
147
+ # defaults to +false+.
148
+ #
149
+ # With the default, +false+:
150
+ # # Raises JSON::ParserError (225: unexpected token at '[NaN]'):
151
+ # JSON.parse('[NaN]')
152
+ # # Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
153
+ # JSON.parse('[Infinity]')
154
+ # # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
155
+ # JSON.parse('[-Infinity]')
156
+ # Allow:
157
+ # source = '[NaN, Infinity, -Infinity]'
158
+ # ruby = JSON.parse(source, {allow_nan: true})
159
+ # ruby # => [NaN, Infinity, -Infinity]
160
+ #
161
+ # ====== Output Options
162
+ #
163
+ # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
164
+ # should be Symbols;
165
+ # defaults to +false+ (use Strings).
166
+ #
167
+ # With the default, +false+:
168
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
169
+ # ruby = JSON.parse(source)
170
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
171
+ # Use Symbols:
172
+ # ruby = JSON.parse(source, {symbolize_names: true})
173
+ # ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
174
+ #
175
+ # ---
176
+ #
177
+ # Option +object_class+ (\Class) specifies the Ruby class to be used
178
+ # for each \JSON object;
179
+ # defaults to \Hash.
180
+ #
181
+ # With the default, \Hash:
182
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
183
+ # ruby = JSON.parse(source)
184
+ # ruby.class # => Hash
185
+ # Use class \OpenStruct:
186
+ # ruby = JSON.parse(source, {object_class: OpenStruct})
187
+ # ruby # => #<OpenStruct a="foo", b=1.0, c=true, d=false, e=nil>
188
+ #
189
+ # ---
190
+ #
191
+ # Option +array_class+ (\Class) specifies the Ruby class to be used
192
+ # for each \JSON array;
193
+ # defaults to \Array.
194
+ #
195
+ # With the default, \Array:
196
+ # source = '["foo", 1.0, true, false, null]'
197
+ # ruby = JSON.parse(source)
198
+ # ruby.class # => Array
199
+ # Use class \Set:
200
+ # ruby = JSON.parse(source, {array_class: Set})
201
+ # ruby # => #<Set: {"foo", 1.0, true, false, nil}>
202
+ #
203
+ # ---
204
+ #
205
+ # Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing.
206
+ # See {\JSON Additions}[#module-JSON-label-JSON+Additions].
207
+ #
208
+ # === Generating \JSON
209
+ #
210
+ # To generate a Ruby \String containing \JSON data,
211
+ # use method <tt>JSON.generate(source, opts)</tt>, where
212
+ # - +source+ is a Ruby object.
213
+ # - +opts+ is a \Hash object containing options
214
+ # that control both input allowed and output formatting.
215
+ #
216
+ # ==== Generating \JSON from Arrays
217
+ #
218
+ # When the source is a Ruby \Array, JSON.generate returns
219
+ # a \String containing a \JSON array:
220
+ # ruby = [0, 's', :foo]
221
+ # json = JSON.generate(ruby)
222
+ # json # => '[0,"s","foo"]'
223
+ #
224
+ # The Ruby \Array array may contain nested arrays, hashes, and scalars
225
+ # to any depth:
226
+ # ruby = [0, [1, 2], {foo: 3, bar: 4}]
227
+ # json = JSON.generate(ruby)
228
+ # json # => '[0,[1,2],{"foo":3,"bar":4}]'
229
+ #
230
+ # ==== Generating \JSON from Hashes
231
+ #
232
+ # When the source is a Ruby \Hash, JSON.generate returns
233
+ # a \String containing a \JSON object:
234
+ # ruby = {foo: 0, bar: 's', baz: :bat}
235
+ # json = JSON.generate(ruby)
236
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
237
+ #
238
+ # The Ruby \Hash array may contain nested arrays, hashes, and scalars
239
+ # to any depth:
240
+ # ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
241
+ # json = JSON.generate(ruby)
242
+ # json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
243
+ #
244
+ # ==== Generating \JSON from Other Objects
245
+ #
246
+ # When the source is neither an \Array nor a \Hash,
247
+ # the generated \JSON data depends on the class of the source.
248
+ #
249
+ # When the source is a Ruby \Integer or \Float, JSON.generate returns
250
+ # a \String containing a \JSON number:
251
+ # JSON.generate(42) # => '42'
252
+ # JSON.generate(0.42) # => '0.42'
253
+ #
254
+ # When the source is a Ruby \String, JSON.generate returns
255
+ # a \String containing a \JSON string (with double-quotes):
256
+ # JSON.generate('A string') # => '"A string"'
257
+ #
258
+ # When the source is +true+, +false+ or +nil+, JSON.generate returns
259
+ # a \String containing the corresponding \JSON token:
260
+ # JSON.generate(true) # => 'true'
261
+ # JSON.generate(false) # => 'false'
262
+ # JSON.generate(nil) # => 'null'
263
+ #
264
+ # When the source is none of the above, JSON.generate returns
265
+ # a \String containing a \JSON string representation of the source:
266
+ # JSON.generate(:foo) # => '"foo"'
267
+ # JSON.generate(Complex(0, 0)) # => '"0+0i"'
268
+ # JSON.generate(Dir.new('.')) # => '"#<Dir>"'
269
+ #
270
+ # ==== Generating Options
271
+ #
272
+ # ====== Input Options
273
+ #
274
+ # Option +allow_nan+ (boolean) specifies whether
275
+ # +NaN+, +Infinity+, and <tt>-Infinity</tt> may be generated;
276
+ # defaults to +false+.
277
+ #
278
+ # With the default, +false+:
279
+ # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
280
+ # JSON.generate(JSON::NaN)
281
+ # # Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
282
+ # JSON.generate(JSON::Infinity)
283
+ # # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
284
+ # JSON.generate(JSON::MinusInfinity)
285
+ #
286
+ # Allow:
287
+ # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
288
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
289
+ #
290
+ # ---
291
+ #
292
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth
293
+ # in +obj+; defaults to +100+.
294
+ #
295
+ # With the default, +100+:
296
+ # obj = [[[[[[0]]]]]]
297
+ # JSON.generate(obj) # => '[[[[[[0]]]]]]'
298
+ #
299
+ # Too deep:
300
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
301
+ # JSON.generate(obj, max_nesting: 2)
302
+ #
303
+ # ====== Escaping Options
304
+ #
305
+ # Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
306
+ # and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
307
+ # tags.
308
+ #
309
+ # Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
310
+ # should be escaped.
311
+ #
312
+ # ====== Output Options
313
+ #
314
+ # The default formatting options generate the most compact
315
+ # \JSON data, all on one line and with no whitespace.
316
+ #
317
+ # You can use these formatting options to generate
318
+ # \JSON data in a more open format, using whitespace.
319
+ # See also JSON.pretty_generate.
320
+ #
321
+ # - Option +array_nl+ (\String) specifies a string (usually a newline)
322
+ # to be inserted after each \JSON array; defaults to the empty \String, <tt>''</tt>.
323
+ # - Option +object_nl+ (\String) specifies a string (usually a newline)
324
+ # to be inserted after each \JSON object; defaults to the empty \String, <tt>''</tt>.
325
+ # - Option +indent+ (\String) specifies the string (usually spaces) to be
326
+ # used for indentation; defaults to the empty \String, <tt>''</tt>;
327
+ # defaults to the empty \String, <tt>''</tt>;
328
+ # has no effect unless options +array_nl+ or +object_nl+ specify newlines.
329
+ # - Option +space+ (\String) specifies a string (usually a space) to be
330
+ # inserted after the colon in each \JSON object's pair;
331
+ # defaults to the empty \String, <tt>''</tt>.
332
+ # - Option +space_before+ (\String) specifies a string (usually a space) to be
333
+ # inserted before the colon in each \JSON object's pair;
334
+ # defaults to the empty \String, <tt>''</tt>.
335
+ #
336
+ # In this example, +obj+ is used first to generate the shortest
337
+ # \JSON data (no whitespace), then again with all formatting options
338
+ # specified:
339
+ #
340
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
341
+ # json = JSON.generate(obj)
342
+ # puts 'Compact:', json
343
+ # opts = {
344
+ # array_nl: "\n",
345
+ # object_nl: "\n",
346
+ # indent: ' ',
347
+ # space_before: ' ',
348
+ # space: ' '
349
+ # }
350
+ # puts 'Open:', JSON.generate(obj, opts)
351
+ #
352
+ # Output:
353
+ # Compact:
354
+ # {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
355
+ # Open:
356
+ # {
357
+ # "foo" : [
358
+ # "bar",
359
+ # "baz"
360
+ # ],
361
+ # "bat" : {
362
+ # "bam" : 0,
363
+ # "bad" : 1
364
+ # }
365
+ # }
366
+ #
367
+ # == \JSON Additions
368
+ #
369
+ # When you "round trip" a non-\String object from Ruby to \JSON and back,
370
+ # you have a new \String, instead of the object you began with:
371
+ # ruby0 = Range.new(0, 2)
372
+ # json = JSON.generate(ruby0)
373
+ # json # => '0..2"'
374
+ # ruby1 = JSON.parse(json)
375
+ # ruby1 # => '0..2'
376
+ # ruby1.class # => String
377
+ #
378
+ # You can use \JSON _additions_ to preserve the original object.
379
+ # The addition is an extension of a ruby class, so that:
380
+ # - \JSON.generate stores more information in the \JSON string.
381
+ # - \JSON.parse, called with option +create_additions+,
382
+ # uses that information to create a proper Ruby object.
383
+ #
384
+ # This example shows a \Range being generated into \JSON
385
+ # and parsed back into Ruby, both without and with
386
+ # the addition for \Range:
387
+ # ruby = Range.new(0, 2)
388
+ # # This passage does not use the addition for Range.
389
+ # json0 = JSON.generate(ruby)
390
+ # ruby0 = JSON.parse(json0)
391
+ # # This passage uses the addition for Range.
392
+ # require 'json/add/range'
393
+ # json1 = JSON.generate(ruby)
394
+ # ruby1 = JSON.parse(json1, create_additions: true)
395
+ # # Make a nice display.
396
+ # display = <<EOT
397
+ # Generated JSON:
398
+ # Without addition: #{json0} (#{json0.class})
399
+ # With addition: #{json1} (#{json1.class})
400
+ # Parsed JSON:
401
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
402
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
403
+ # EOT
404
+ # puts display
405
+ #
406
+ # This output shows the different results:
407
+ # Generated JSON:
408
+ # Without addition: "0..2" (String)
409
+ # With addition: {"json_class":"Range","a":[0,2,false]} (String)
410
+ # Parsed JSON:
411
+ # Without addition: "0..2" (String)
412
+ # With addition: 0..2 (Range)
413
+ #
414
+ # The \JSON module includes additions for certain classes.
415
+ # You can also craft custom additions.
416
+ # See {Custom \JSON Additions}[#module-JSON-label-Custom+JSON+Additions].
417
+ #
418
+ # === Built-in Additions
419
+ #
420
+ # The \JSON module includes additions for certain classes.
421
+ # To use an addition, +require+ its source:
422
+ # - BigDecimal: <tt>require 'json/add/bigdecimal'</tt>
423
+ # - Complex: <tt>require 'json/add/complex'</tt>
424
+ # - Date: <tt>require 'json/add/date'</tt>
425
+ # - DateTime: <tt>require 'json/add/date_time'</tt>
426
+ # - Exception: <tt>require 'json/add/exception'</tt>
427
+ # - OpenStruct: <tt>require 'json/add/ostruct'</tt>
428
+ # - Range: <tt>require 'json/add/range'</tt>
429
+ # - Rational: <tt>require 'json/add/rational'</tt>
430
+ # - Regexp: <tt>require 'json/add/regexp'</tt>
431
+ # - Set: <tt>require 'json/add/set'</tt>
432
+ # - Struct: <tt>require 'json/add/struct'</tt>
433
+ # - Symbol: <tt>require 'json/add/symbol'</tt>
434
+ # - Time: <tt>require 'json/add/time'</tt>
435
+ #
436
+ # To reduce punctuation clutter, the examples below
437
+ # show the generated \JSON via +puts+, rather than the usual +inspect+,
438
+ #
439
+ # \BigDecimal:
440
+ # require 'json/add/bigdecimal'
441
+ # ruby0 = BigDecimal(0) # 0.0
442
+ # json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"}
443
+ # ruby1 = JSON.parse(json, create_additions: true) # 0.0
444
+ # ruby1.class # => BigDecimal
445
+ #
446
+ # \Complex:
447
+ # require 'json/add/complex'
448
+ # ruby0 = Complex(1+0i) # 1+0i
449
+ # json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0}
450
+ # ruby1 = JSON.parse(json, create_additions: true) # 1+0i
451
+ # ruby1.class # Complex
452
+ #
453
+ # \Date:
454
+ # require 'json/add/date'
455
+ # ruby0 = Date.today # 2020-05-02
456
+ # json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0}
457
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02
458
+ # ruby1.class # Date
459
+ #
460
+ # \DateTime:
461
+ # require 'json/add/date_time'
462
+ # ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00
463
+ # 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}
464
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00
465
+ # ruby1.class # DateTime
466
+ #
467
+ # \Exception (and its subclasses including \RuntimeError):
468
+ # require 'json/add/exception'
469
+ # ruby0 = Exception.new('A message') # A message
470
+ # json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null}
471
+ # ruby1 = JSON.parse(json, create_additions: true) # A message
472
+ # ruby1.class # Exception
473
+ # ruby0 = RuntimeError.new('Another message') # Another message
474
+ # json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null}
475
+ # ruby1 = JSON.parse(json, create_additions: true) # Another message
476
+ # ruby1.class # RuntimeError
477
+ #
478
+ # \OpenStruct:
479
+ # require 'json/add/ostruct'
480
+ # ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # #<OpenStruct name="Matz", language="Ruby">
481
+ # json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}}
482
+ # ruby1 = JSON.parse(json, create_additions: true) # #<OpenStruct name="Matz", language="Ruby">
483
+ # ruby1.class # OpenStruct
484
+ #
485
+ # \Range:
486
+ # require 'json/add/range'
487
+ # ruby0 = Range.new(0, 2) # 0..2
488
+ # json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]}
489
+ # ruby1 = JSON.parse(json, create_additions: true) # 0..2
490
+ # ruby1.class # Range
491
+ #
492
+ # \Rational:
493
+ # require 'json/add/rational'
494
+ # ruby0 = Rational(1, 3) # 1/3
495
+ # json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3}
496
+ # ruby1 = JSON.parse(json, create_additions: true) # 1/3
497
+ # ruby1.class # Rational
498
+ #
499
+ # \Regexp:
500
+ # require 'json/add/regexp'
501
+ # ruby0 = Regexp.new('foo') # (?-mix:foo)
502
+ # json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"}
503
+ # ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo)
504
+ # ruby1.class # Regexp
505
+ #
506
+ # \Set:
507
+ # require 'json/add/set'
508
+ # ruby0 = Set.new([0, 1, 2]) # #<Set: {0, 1, 2}>
509
+ # json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]}
510
+ # ruby1 = JSON.parse(json, create_additions: true) # #<Set: {0, 1, 2}>
511
+ # ruby1.class # Set
512
+ #
513
+ # \Struct:
514
+ # require 'json/add/struct'
515
+ # Customer = Struct.new(:name, :address) # Customer
516
+ # ruby0 = Customer.new("Dave", "123 Main") # #<struct Customer name="Dave", address="123 Main">
517
+ # json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]}
518
+ # ruby1 = JSON.parse(json, create_additions: true) # #<struct Customer name="Dave", address="123 Main">
519
+ # ruby1.class # Customer
520
+ #
521
+ # \Symbol:
522
+ # require 'json/add/symbol'
523
+ # ruby0 = :foo # foo
524
+ # json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"}
525
+ # ruby1 = JSON.parse(json, create_additions: true) # foo
526
+ # ruby1.class # Symbol
527
+ #
528
+ # \Time:
529
+ # require 'json/add/time'
530
+ # ruby0 = Time.now # 2020-05-02 11:28:26 -0500
531
+ # json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000}
532
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500
533
+ # ruby1.class # Time
534
+ #
535
+ #
536
+ # === Custom \JSON Additions
537
+ #
538
+ # In addition to the \JSON additions provided,
539
+ # you can craft \JSON additions of your own,
540
+ # either for Ruby built-in classes or for user-defined classes.
541
+ #
542
+ # Here's a user-defined class +Foo+:
543
+ # class Foo
544
+ # attr_accessor :bar, :baz
545
+ # def initialize(bar, baz)
546
+ # self.bar = bar
547
+ # self.baz = baz
548
+ # end
549
+ # end
550
+ #
551
+ # Here's the \JSON addition for it:
552
+ # # Extend class Foo with JSON addition.
553
+ # class Foo
554
+ # # Serialize Foo object with its class name and arguments
555
+ # def to_json(*args)
556
+ # {
557
+ # JSON.create_id => self.class.name,
558
+ # 'a' => [ bar, baz ]
559
+ # }.to_json(*args)
560
+ # end
561
+ # # Deserialize JSON string by constructing new Foo object with arguments.
562
+ # def self.json_create(object)
563
+ # new(*object['a'])
564
+ # end
565
+ # end
566
+ #
567
+ # Demonstration:
568
+ # require 'json'
569
+ # # This Foo object has no custom addition.
570
+ # foo0 = Foo.new(0, 1)
571
+ # json0 = JSON.generate(foo0)
572
+ # obj0 = JSON.parse(json0)
573
+ # # Lood the custom addition.
574
+ # require_relative 'foo_addition'
575
+ # # This foo has the custom addition.
576
+ # foo1 = Foo.new(0, 1)
577
+ # json1 = JSON.generate(foo1)
578
+ # obj1 = JSON.parse(json1, create_additions: true)
579
+ # # Make a nice display.
580
+ # display = <<EOT
581
+ # Generated JSON:
582
+ # Without custom addition: #{json0} (#{json0.class})
583
+ # With custom addition: #{json1} (#{json1.class})
584
+ # Parsed JSON:
585
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
586
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
587
+ # EOT
588
+ # puts display
589
+ #
590
+ # Output:
591
+ #
592
+ # Generated JSON:
593
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
594
+ # With custom addition: {"json_class":"Foo","a":[0,1]} (String)
595
+ # Parsed JSON:
596
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
597
+ # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
598
+ module JSON
599
+ private
600
+
601
+ # :call-seq:
602
+ # JSON.dump(obj, io = nil, limit = nil)
603
+ #
604
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
605
+ #
606
+ # The default options can be changed via method JSON.dump_default_options.
607
+ #
608
+ # - Argument +io+, if given, should respond to method +write+;
609
+ # the \JSON \String is written to +io+, and +io+ is returned.
610
+ # If +io+ is not given, the \JSON \String is returned.
611
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
612
+ #
613
+ # ---
614
+ #
615
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
616
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
617
+ # json = JSON.dump(obj)
618
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
619
+ #
620
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
621
+ # path = 't.json'
622
+ # File.open(path, 'w') do |file|
623
+ # JSON.dump(obj, file)
624
+ # end # => #<File:t.json (closed)>
625
+ # puts File.read(path)
626
+ # Output:
627
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
628
+ #
629
+ # source://json//json/common.rb#614
630
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
631
+
632
+ # :call-seq:
633
+ # JSON.fast_generate(obj, opts) -> new_string
634
+ #
635
+ # Arguments +obj+ and +opts+ here are the same as
636
+ # arguments +obj+ and +opts+ in JSON.generate.
637
+ #
638
+ # By default, generates \JSON data without checking
639
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
640
+ #
641
+ # Raises an exception if +obj+ contains circular references:
642
+ # a = []; b = []; a.push(b); b.push(a)
643
+ # # Raises SystemStackError (stack level too deep):
644
+ # JSON.fast_generate(a)
645
+ #
646
+ # source://json//json/common.rb#328
647
+ def fast_generate(obj, opts = T.unsafe(nil)); end
648
+
649
+ # :stopdoc:
650
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
651
+ #
652
+ # source://json//json/common.rb#328
653
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
654
+
655
+ # :call-seq:
656
+ # JSON.generate(obj, opts = nil) -> new_string
657
+ #
658
+ # Returns a \String containing the generated \JSON data.
659
+ #
660
+ # See also JSON.fast_generate, JSON.pretty_generate.
661
+ #
662
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
663
+ #
664
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
665
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
666
+ #
667
+ # ---
668
+ #
669
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
670
+ # obj = ["foo", 1.0, true, false, nil]
671
+ # json = JSON.generate(obj)
672
+ # json # => '["foo",1.0,true,false,null]'
673
+ #
674
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
675
+ # obj = {foo: 0, bar: 's', baz: :bat}
676
+ # json = JSON.generate(obj)
677
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
678
+ #
679
+ # For examples of generating from other Ruby objects, see
680
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
681
+ #
682
+ # ---
683
+ #
684
+ # Raises an exception if any formatting option is not a \String.
685
+ #
686
+ # Raises an exception if +obj+ contains circular references:
687
+ # a = []; b = []; a.push(b); b.push(a)
688
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
689
+ # JSON.generate(a)
690
+ #
691
+ # source://json//json/common.rb#299
692
+ def generate(obj, opts = T.unsafe(nil)); end
693
+
694
+ # :call-seq:
695
+ # JSON.load(source, proc = nil, options = {}) -> object
696
+ #
697
+ # Returns the Ruby objects created by parsing the given +source+.
698
+ #
699
+ # - Argument +source+ must be, or be convertible to, a \String:
700
+ # - If +source+ responds to instance method +to_str+,
701
+ # <tt>source.to_str</tt> becomes the source.
702
+ # - If +source+ responds to instance method +to_io+,
703
+ # <tt>source.to_io.read</tt> becomes the source.
704
+ # - If +source+ responds to instance method +read+,
705
+ # <tt>source.read</tt> becomes the source.
706
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
707
+ # - Option +allow_blank+ specifies a truthy value.
708
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
709
+ # - Otherwise, +source+ remains the source.
710
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
711
+ # It will be called recursively with each result (depth-first order).
712
+ # See details below.
713
+ # BEWARE: This method is meant to serialise data from trusted user input,
714
+ # like from your own database server or clients under your control, it could
715
+ # be dangerous to allow untrusted users to pass JSON sources into it.
716
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
717
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
718
+ # The default options can be changed via method JSON.load_default_options=.
719
+ #
720
+ # ---
721
+ #
722
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
723
+ # <tt>parse(source, opts)</tt>; see #parse.
724
+ #
725
+ # Source for following examples:
726
+ # source = <<-EOT
727
+ # {
728
+ # "name": "Dave",
729
+ # "age" :40,
730
+ # "hats": [
731
+ # "Cattleman's",
732
+ # "Panama",
733
+ # "Tophat"
734
+ # ]
735
+ # }
736
+ # EOT
737
+ #
738
+ # Load a \String:
739
+ # ruby = JSON.load(source)
740
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
741
+ #
742
+ # Load an \IO object:
743
+ # require 'stringio'
744
+ # object = JSON.load(StringIO.new(source))
745
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
746
+ #
747
+ # Load a \File object:
748
+ # path = 't.json'
749
+ # File.write(path, source)
750
+ # File.open(path) do |file|
751
+ # JSON.load(file)
752
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
753
+ #
754
+ # ---
755
+ #
756
+ # When +proc+ is given:
757
+ # - Modifies +source+ as above.
758
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
759
+ # - Recursively calls <tt>proc(result)</tt>.
760
+ # - Returns the final result.
761
+ #
762
+ # Example:
763
+ # require 'json'
764
+ #
765
+ # # Some classes for the example.
766
+ # class Base
767
+ # def initialize(attributes)
768
+ # @attributes = attributes
769
+ # end
770
+ # end
771
+ # class User < Base; end
772
+ # class Account < Base; end
773
+ # class Admin < Base; end
774
+ # # The JSON source.
775
+ # json = <<-EOF
776
+ # {
777
+ # "users": [
778
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
779
+ # {"type": "User", "username": "john", "email": "john@example.com"}
780
+ # ],
781
+ # "accounts": [
782
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
783
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
784
+ # ],
785
+ # "admins": {"type": "Admin", "password": "0wn3d"}
786
+ # }
787
+ # EOF
788
+ # # Deserializer method.
789
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
790
+ # type = obj.is_a?(Hash) && obj["type"]
791
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
792
+ # end
793
+ # # Call to JSON.load
794
+ # ruby = JSON.load(json, proc {|obj|
795
+ # case obj
796
+ # when Hash
797
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
798
+ # when Array
799
+ # obj.map! {|v| deserialize_obj v }
800
+ # end
801
+ # })
802
+ # pp ruby
803
+ # Output:
804
+ # {"users"=>
805
+ # [#<User:0x00000000064c4c98
806
+ # @attributes=
807
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
808
+ # #<User:0x00000000064c4bd0
809
+ # @attributes=
810
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
811
+ # "accounts"=>
812
+ # [{"account"=>
813
+ # #<Account:0x00000000064c4928
814
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
815
+ # {"account"=>
816
+ # #<Account:0x00000000064c4680
817
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
818
+ # "admins"=>
819
+ # #<Admin:0x00000000064c41f8
820
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
821
+ #
822
+ # source://json//json/common.rb#540
823
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
824
+
825
+ # :call-seq:
826
+ # JSON.load_file(path, opts={}) -> object
827
+ #
828
+ # Calls:
829
+ # parse(File.read(path), opts)
830
+ #
831
+ # See method #parse.
832
+ #
833
+ # source://json//json/common.rb#248
834
+ def load_file(filespec, opts = T.unsafe(nil)); end
835
+
836
+ # :call-seq:
837
+ # JSON.load_file!(path, opts = {})
838
+ #
839
+ # Calls:
840
+ # JSON.parse!(File.read(path, opts))
841
+ #
842
+ # See method #parse!
843
+ #
844
+ # source://json//json/common.rb#259
845
+ def load_file!(filespec, opts = T.unsafe(nil)); end
846
+
847
+ # source://json//json/common.rb#642
848
+ def merge_dump_options(opts, strict: T.unsafe(nil)); end
849
+
850
+ # :call-seq:
851
+ # JSON.parse(source, opts) -> object
852
+ #
853
+ # Returns the Ruby objects created by parsing the given +source+.
854
+ #
855
+ # Argument +source+ contains the \String to be parsed.
856
+ #
857
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
858
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
859
+ #
860
+ # ---
861
+ #
862
+ # When +source+ is a \JSON array, returns a Ruby \Array:
863
+ # source = '["foo", 1.0, true, false, null]'
864
+ # ruby = JSON.parse(source)
865
+ # ruby # => ["foo", 1.0, true, false, nil]
866
+ # ruby.class # => Array
867
+ #
868
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
869
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
870
+ # ruby = JSON.parse(source)
871
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
872
+ # ruby.class # => Hash
873
+ #
874
+ # For examples of parsing for all \JSON data types, see
875
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
876
+ #
877
+ # Parses nested JSON objects:
878
+ # source = <<-EOT
879
+ # {
880
+ # "name": "Dave",
881
+ # "age" :40,
882
+ # "hats": [
883
+ # "Cattleman's",
884
+ # "Panama",
885
+ # "Tophat"
886
+ # ]
887
+ # }
888
+ # EOT
889
+ # ruby = JSON.parse(source)
890
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
891
+ #
892
+ # ---
893
+ #
894
+ # Raises an exception if +source+ is not valid JSON:
895
+ # # Raises JSON::ParserError (783: unexpected token at ''):
896
+ # JSON.parse('')
897
+ #
898
+ # source://json//json/common.rb#218
899
+ def parse(source, opts = T.unsafe(nil)); end
900
+
901
+ # :call-seq:
902
+ # JSON.parse!(source, opts) -> object
903
+ #
904
+ # Calls
905
+ # parse(source, opts)
906
+ # with +source+ and possibly modified +opts+.
907
+ #
908
+ # Differences from JSON.parse:
909
+ # - Option +max_nesting+, if not provided, defaults to +false+,
910
+ # which disables checking for nesting depth.
911
+ # - Option +allow_nan+, if not provided, defaults to +true+.
912
+ #
913
+ # source://json//json/common.rb#233
914
+ def parse!(source, opts = T.unsafe(nil)); end
915
+
916
+ # :call-seq:
917
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
918
+ #
919
+ # Arguments +obj+ and +opts+ here are the same as
920
+ # arguments +obj+ and +opts+ in JSON.generate.
921
+ #
922
+ # Default options are:
923
+ # {
924
+ # indent: ' ', # Two spaces
925
+ # space: ' ', # One space
926
+ # array_nl: "\n", # Newline
927
+ # object_nl: "\n" # Newline
928
+ # }
929
+ #
930
+ # Example:
931
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
932
+ # json = JSON.pretty_generate(obj)
933
+ # puts json
934
+ # Output:
935
+ # {
936
+ # "foo": [
937
+ # "bar",
938
+ # "baz"
939
+ # ],
940
+ # "bat": {
941
+ # "bam": 0,
942
+ # "bad": 1
943
+ # }
944
+ # }
945
+ #
946
+ # source://json//json/common.rb#373
947
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
948
+
949
+ # :stopdoc:
950
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
951
+ #
952
+ # source://json//json/common.rb#373
953
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
954
+
955
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
956
+ #
957
+ # source://json//json/common.rb#558
958
+ def recurse_proc(result, &proc); end
959
+
960
+ # source://json//json/common.rb#540
961
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
962
+
963
+ # :stopdoc:
964
+ # I want to deprecate these later, so I'll first be silent about them, and
965
+ # later delete them.
966
+ #
967
+ # source://json//json/common.rb#299
968
+ def unparse(obj, opts = T.unsafe(nil)); end
969
+
970
+ class << self
971
+ # :call-seq:
972
+ # JSON[object] -> new_array or new_string
973
+ #
974
+ # If +object+ is a \String,
975
+ # calls JSON.parse with +object+ and +opts+ (see method #parse):
976
+ # json = '[0, 1, null]'
977
+ # JSON[json]# => [0, 1, nil]
978
+ #
979
+ # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
980
+ # ruby = [0, 1, nil]
981
+ # JSON[ruby] # => '[0,1,null]'
982
+ #
983
+ # source://json//json/common.rb#21
984
+ def [](object, opts = T.unsafe(nil)); end
985
+
986
+ # source://json//json/common.rb#84
987
+ def create_fast_state; end
988
+
989
+ # Returns the current create identifier.
990
+ # See also JSON.create_id=.
991
+ #
992
+ # source://json//json/common.rb#129
993
+ def create_id; end
994
+
995
+ # Sets create identifier, which is used to decide if the _json_create_
996
+ # hook of a class should be called; initial value is +json_class+:
997
+ # JSON.create_id # => 'json_class'
998
+ #
999
+ # source://json//json/common.rb#123
1000
+ def create_id=(new_value); end
1001
+
1002
+ # source://json//json/common.rb#94
1003
+ def create_pretty_state; end
1004
+
1005
+ # Return the constant located at _path_. The format of _path_ has to be
1006
+ # either ::A::B::C or A::B::C. In any case, A has to be located at the top
1007
+ # level (absolute namespace path?). If there doesn't exist a constant at
1008
+ # the given path, an ArgumentError is raised.
1009
+ #
1010
+ # source://json//json/common.rb#45
1011
+ def deep_const_get(path); end
1012
+
1013
+ # :call-seq:
1014
+ # JSON.dump(obj, io = nil, limit = nil)
1015
+ #
1016
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
1017
+ #
1018
+ # The default options can be changed via method JSON.dump_default_options.
1019
+ #
1020
+ # - Argument +io+, if given, should respond to method +write+;
1021
+ # the \JSON \String is written to +io+, and +io+ is returned.
1022
+ # If +io+ is not given, the \JSON \String is returned.
1023
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
1024
+ #
1025
+ # ---
1026
+ #
1027
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
1028
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
1029
+ # json = JSON.dump(obj)
1030
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
1031
+ #
1032
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
1033
+ # path = 't.json'
1034
+ # File.open(path, 'w') do |file|
1035
+ # JSON.dump(obj, file)
1036
+ # end # => #<File:t.json (closed)>
1037
+ # puts File.read(path)
1038
+ # Output:
1039
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1040
+ #
1041
+ # source://json//json/common.rb#614
1042
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1043
+
1044
+ # Sets or returns the default options for the JSON.dump method.
1045
+ # Initially:
1046
+ # opts = JSON.dump_default_options
1047
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1048
+ #
1049
+ # source://json//json/common.rb#579
1050
+ def dump_default_options; end
1051
+
1052
+ # Sets or returns the default options for the JSON.dump method.
1053
+ # Initially:
1054
+ # opts = JSON.dump_default_options
1055
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1056
+ #
1057
+ # source://json//json/common.rb#579
1058
+ def dump_default_options=(_arg0); end
1059
+
1060
+ # :call-seq:
1061
+ # JSON.fast_generate(obj, opts) -> new_string
1062
+ #
1063
+ # Arguments +obj+ and +opts+ here are the same as
1064
+ # arguments +obj+ and +opts+ in JSON.generate.
1065
+ #
1066
+ # By default, generates \JSON data without checking
1067
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
1068
+ #
1069
+ # Raises an exception if +obj+ contains circular references:
1070
+ # a = []; b = []; a.push(b); b.push(a)
1071
+ # # Raises SystemStackError (stack level too deep):
1072
+ # JSON.fast_generate(a)
1073
+ #
1074
+ # source://json//json/common.rb#328
1075
+ def fast_generate(obj, opts = T.unsafe(nil)); end
1076
+
1077
+ # :stopdoc:
1078
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1079
+ #
1080
+ # source://json//json/common.rb#328
1081
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
1082
+
1083
+ # :call-seq:
1084
+ # JSON.generate(obj, opts = nil) -> new_string
1085
+ #
1086
+ # Returns a \String containing the generated \JSON data.
1087
+ #
1088
+ # See also JSON.fast_generate, JSON.pretty_generate.
1089
+ #
1090
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
1091
+ #
1092
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1093
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
1094
+ #
1095
+ # ---
1096
+ #
1097
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
1098
+ # obj = ["foo", 1.0, true, false, nil]
1099
+ # json = JSON.generate(obj)
1100
+ # json # => '["foo",1.0,true,false,null]'
1101
+ #
1102
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
1103
+ # obj = {foo: 0, bar: 's', baz: :bat}
1104
+ # json = JSON.generate(obj)
1105
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
1106
+ #
1107
+ # For examples of generating from other Ruby objects, see
1108
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
1109
+ #
1110
+ # ---
1111
+ #
1112
+ # Raises an exception if any formatting option is not a \String.
1113
+ #
1114
+ # Raises an exception if +obj+ contains circular references:
1115
+ # a = []; b = []; a.push(b); b.push(a)
1116
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
1117
+ # JSON.generate(a)
1118
+ #
1119
+ # source://json//json/common.rb#299
1120
+ def generate(obj, opts = T.unsafe(nil)); end
1121
+
1122
+ # Returns the JSON generator module that is used by JSON. This is
1123
+ # either JSON::Ext::Generator or JSON::Pure::Generator:
1124
+ # JSON.generator # => JSON::Ext::Generator
1125
+ #
1126
+ # source://json//json/common.rb#106
1127
+ def generator; end
1128
+
1129
+ # Set the module _generator_ to be used by JSON.
1130
+ #
1131
+ # source://json//json/common.rb#61
1132
+ def generator=(generator); end
1133
+
1134
+ # Encodes string using String.encode.
1135
+ #
1136
+ # source://json//json/common.rb#638
1137
+ def iconv(to, from, string); end
1138
+
1139
+ # :call-seq:
1140
+ # JSON.load(source, proc = nil, options = {}) -> object
1141
+ #
1142
+ # Returns the Ruby objects created by parsing the given +source+.
1143
+ #
1144
+ # - Argument +source+ must be, or be convertible to, a \String:
1145
+ # - If +source+ responds to instance method +to_str+,
1146
+ # <tt>source.to_str</tt> becomes the source.
1147
+ # - If +source+ responds to instance method +to_io+,
1148
+ # <tt>source.to_io.read</tt> becomes the source.
1149
+ # - If +source+ responds to instance method +read+,
1150
+ # <tt>source.read</tt> becomes the source.
1151
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1152
+ # - Option +allow_blank+ specifies a truthy value.
1153
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1154
+ # - Otherwise, +source+ remains the source.
1155
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1156
+ # It will be called recursively with each result (depth-first order).
1157
+ # See details below.
1158
+ # BEWARE: This method is meant to serialise data from trusted user input,
1159
+ # like from your own database server or clients under your control, it could
1160
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1161
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1162
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1163
+ # The default options can be changed via method JSON.load_default_options=.
1164
+ #
1165
+ # ---
1166
+ #
1167
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1168
+ # <tt>parse(source, opts)</tt>; see #parse.
1169
+ #
1170
+ # Source for following examples:
1171
+ # source = <<-EOT
1172
+ # {
1173
+ # "name": "Dave",
1174
+ # "age" :40,
1175
+ # "hats": [
1176
+ # "Cattleman's",
1177
+ # "Panama",
1178
+ # "Tophat"
1179
+ # ]
1180
+ # }
1181
+ # EOT
1182
+ #
1183
+ # Load a \String:
1184
+ # ruby = JSON.load(source)
1185
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1186
+ #
1187
+ # Load an \IO object:
1188
+ # require 'stringio'
1189
+ # object = JSON.load(StringIO.new(source))
1190
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1191
+ #
1192
+ # Load a \File object:
1193
+ # path = 't.json'
1194
+ # File.write(path, source)
1195
+ # File.open(path) do |file|
1196
+ # JSON.load(file)
1197
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1198
+ #
1199
+ # ---
1200
+ #
1201
+ # When +proc+ is given:
1202
+ # - Modifies +source+ as above.
1203
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1204
+ # - Recursively calls <tt>proc(result)</tt>.
1205
+ # - Returns the final result.
1206
+ #
1207
+ # Example:
1208
+ # require 'json'
1209
+ #
1210
+ # # Some classes for the example.
1211
+ # class Base
1212
+ # def initialize(attributes)
1213
+ # @attributes = attributes
1214
+ # end
1215
+ # end
1216
+ # class User < Base; end
1217
+ # class Account < Base; end
1218
+ # class Admin < Base; end
1219
+ # # The JSON source.
1220
+ # json = <<-EOF
1221
+ # {
1222
+ # "users": [
1223
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1224
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1225
+ # ],
1226
+ # "accounts": [
1227
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1228
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1229
+ # ],
1230
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1231
+ # }
1232
+ # EOF
1233
+ # # Deserializer method.
1234
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1235
+ # type = obj.is_a?(Hash) && obj["type"]
1236
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1237
+ # end
1238
+ # # Call to JSON.load
1239
+ # ruby = JSON.load(json, proc {|obj|
1240
+ # case obj
1241
+ # when Hash
1242
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1243
+ # when Array
1244
+ # obj.map! {|v| deserialize_obj v }
1245
+ # end
1246
+ # })
1247
+ # pp ruby
1248
+ # Output:
1249
+ # {"users"=>
1250
+ # [#<User:0x00000000064c4c98
1251
+ # @attributes=
1252
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1253
+ # #<User:0x00000000064c4bd0
1254
+ # @attributes=
1255
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1256
+ # "accounts"=>
1257
+ # [{"account"=>
1258
+ # #<Account:0x00000000064c4928
1259
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1260
+ # {"account"=>
1261
+ # #<Account:0x00000000064c4680
1262
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1263
+ # "admins"=>
1264
+ # #<Admin:0x00000000064c41f8
1265
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1266
+ #
1267
+ # source://json//json/common.rb#540
1268
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1269
+
1270
+ # Sets or returns default options for the JSON.load method.
1271
+ # Initially:
1272
+ # opts = JSON.load_default_options
1273
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1274
+ #
1275
+ # source://json//json/common.rb#403
1276
+ def load_default_options; end
1277
+
1278
+ # Sets or returns default options for the JSON.load method.
1279
+ # Initially:
1280
+ # opts = JSON.load_default_options
1281
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1282
+ #
1283
+ # source://json//json/common.rb#403
1284
+ def load_default_options=(_arg0); end
1285
+
1286
+ # :call-seq:
1287
+ # JSON.load_file(path, opts={}) -> object
1288
+ #
1289
+ # Calls:
1290
+ # parse(File.read(path), opts)
1291
+ #
1292
+ # See method #parse.
1293
+ #
1294
+ # source://json//json/common.rb#248
1295
+ def load_file(filespec, opts = T.unsafe(nil)); end
1296
+
1297
+ # :call-seq:
1298
+ # JSON.load_file!(path, opts = {})
1299
+ #
1300
+ # Calls:
1301
+ # JSON.parse!(File.read(path, opts))
1302
+ #
1303
+ # See method #parse!
1304
+ #
1305
+ # source://json//json/common.rb#259
1306
+ def load_file!(filespec, opts = T.unsafe(nil)); end
1307
+
1308
+ # :call-seq:
1309
+ # JSON.parse(source, opts) -> object
1310
+ #
1311
+ # Returns the Ruby objects created by parsing the given +source+.
1312
+ #
1313
+ # Argument +source+ contains the \String to be parsed.
1314
+ #
1315
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
1316
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1317
+ #
1318
+ # ---
1319
+ #
1320
+ # When +source+ is a \JSON array, returns a Ruby \Array:
1321
+ # source = '["foo", 1.0, true, false, null]'
1322
+ # ruby = JSON.parse(source)
1323
+ # ruby # => ["foo", 1.0, true, false, nil]
1324
+ # ruby.class # => Array
1325
+ #
1326
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
1327
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
1328
+ # ruby = JSON.parse(source)
1329
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
1330
+ # ruby.class # => Hash
1331
+ #
1332
+ # For examples of parsing for all \JSON data types, see
1333
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1334
+ #
1335
+ # Parses nested JSON objects:
1336
+ # source = <<-EOT
1337
+ # {
1338
+ # "name": "Dave",
1339
+ # "age" :40,
1340
+ # "hats": [
1341
+ # "Cattleman's",
1342
+ # "Panama",
1343
+ # "Tophat"
1344
+ # ]
1345
+ # }
1346
+ # EOT
1347
+ # ruby = JSON.parse(source)
1348
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1349
+ #
1350
+ # ---
1351
+ #
1352
+ # Raises an exception if +source+ is not valid JSON:
1353
+ # # Raises JSON::ParserError (783: unexpected token at ''):
1354
+ # JSON.parse('')
1355
+ #
1356
+ # source://json//json/common.rb#218
1357
+ def parse(source, opts = T.unsafe(nil)); end
1358
+
1359
+ # :call-seq:
1360
+ # JSON.parse!(source, opts) -> object
1361
+ #
1362
+ # Calls
1363
+ # parse(source, opts)
1364
+ # with +source+ and possibly modified +opts+.
1365
+ #
1366
+ # Differences from JSON.parse:
1367
+ # - Option +max_nesting+, if not provided, defaults to +false+,
1368
+ # which disables checking for nesting depth.
1369
+ # - Option +allow_nan+, if not provided, defaults to +true+.
1370
+ #
1371
+ # source://json//json/common.rb#233
1372
+ def parse!(source, opts = T.unsafe(nil)); end
1373
+
1374
+ # Returns the JSON parser class that is used by JSON. This is either
1375
+ # JSON::Ext::Parser or JSON::Pure::Parser:
1376
+ # JSON.parser # => JSON::Ext::Parser
1377
+ #
1378
+ # source://json//json/common.rb#32
1379
+ def parser; end
1380
+
1381
+ # Set the JSON parser class _parser_ to be used by JSON.
1382
+ #
1383
+ # source://json//json/common.rb#35
1384
+ def parser=(parser); end
1385
+
1386
+ # :call-seq:
1387
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
1388
+ #
1389
+ # Arguments +obj+ and +opts+ here are the same as
1390
+ # arguments +obj+ and +opts+ in JSON.generate.
1391
+ #
1392
+ # Default options are:
1393
+ # {
1394
+ # indent: ' ', # Two spaces
1395
+ # space: ' ', # One space
1396
+ # array_nl: "\n", # Newline
1397
+ # object_nl: "\n" # Newline
1398
+ # }
1399
+ #
1400
+ # Example:
1401
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
1402
+ # json = JSON.pretty_generate(obj)
1403
+ # puts json
1404
+ # Output:
1405
+ # {
1406
+ # "foo": [
1407
+ # "bar",
1408
+ # "baz"
1409
+ # ],
1410
+ # "bat": {
1411
+ # "bam": 0,
1412
+ # "bad": 1
1413
+ # }
1414
+ # }
1415
+ #
1416
+ # source://json//json/common.rb#373
1417
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
1418
+
1419
+ # :stopdoc:
1420
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1421
+ #
1422
+ # source://json//json/common.rb#373
1423
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
1424
+
1425
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1426
+ #
1427
+ # source://json//json/common.rb#558
1428
+ def recurse_proc(result, &proc); end
1429
+
1430
+ # source://json//json/common.rb#540
1431
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1432
+
1433
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1434
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1435
+ # JSON.state # => JSON::Ext::Generator::State
1436
+ #
1437
+ # source://json//json/common.rb#111
1438
+ def state; end
1439
+
1440
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1441
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1442
+ # JSON.state # => JSON::Ext::Generator::State
1443
+ #
1444
+ # source://json//json/common.rb#111
1445
+ def state=(_arg0); end
1446
+
1447
+ # :stopdoc:
1448
+ # I want to deprecate these later, so I'll first be silent about them, and
1449
+ # later delete them.
1450
+ #
1451
+ # source://json//json/common.rb#299
1452
+ def unparse(obj, opts = T.unsafe(nil)); end
1453
+
1454
+ private
1455
+
1456
+ # source://json//json/common.rb#642
1457
+ def merge_dump_options(opts, strict: T.unsafe(nil)); end
1458
+ end
1459
+ end
1460
+
1461
+ # source://json//json/common.rb#117
1462
+ JSON::CREATE_ID_TLS_KEY = T.let(T.unsafe(nil), String)
1463
+
1464
+ # source://json//json/common.rb#114
1465
+ JSON::DEFAULT_CREATE_ID = T.let(T.unsafe(nil), String)
1466
+
1467
+ class JSON::GenericObject < ::OpenStruct
1468
+ # source://json//json/generic_object.rb#63
1469
+ def as_json(*_arg0); end
1470
+
1471
+ # source://json//json/generic_object.rb#47
1472
+ def to_hash; end
1473
+
1474
+ # source://json//json/generic_object.rb#67
1475
+ def to_json(*a); end
1476
+
1477
+ # source://json//json/generic_object.rb#59
1478
+ def |(other); end
1479
+
1480
+ class << self
1481
+ # source://json//json/generic_object.rb#41
1482
+ def dump(obj, *args); end
1483
+
1484
+ # source://json//json/generic_object.rb#21
1485
+ def from_hash(object); end
1486
+
1487
+ # Sets the attribute json_creatable
1488
+ #
1489
+ # @param value the value to set the attribute json_creatable to.
1490
+ #
1491
+ # source://json//json/generic_object.rb#13
1492
+ def json_creatable=(_arg0); end
1493
+
1494
+ # @return [Boolean]
1495
+ #
1496
+ # source://json//json/generic_object.rb#9
1497
+ def json_creatable?; end
1498
+
1499
+ # source://json//json/generic_object.rb#15
1500
+ def json_create(data); end
1501
+
1502
+ # source://json//json/generic_object.rb#36
1503
+ def load(source, proc = T.unsafe(nil), opts = T.unsafe(nil)); end
1504
+ end
1505
+ end
1506
+
1507
+ # The base exception for JSON errors.
1508
+ class JSON::JSONError < ::StandardError
1509
+ class << self
1510
+ # source://json//json/common.rb#141
1511
+ def wrap(exception); end
1512
+ end
1513
+ end
1514
+
1515
+ # source://json//json/common.rb#6
1516
+ JSON::NOT_SET = T.let(T.unsafe(nil), Object)
1517
+
1518
+ # source://json//json/common.rb#38
1519
+ JSON::Parser = JSON::Ext::Parser
1520
+
1521
+ # source://json//json/common.rb#76
1522
+ JSON::State = JSON::Ext::Generator::State
1523
+
1524
+ # For backwards compatibility
1525
+ #
1526
+ # source://json//json/common.rb#162
1527
+ JSON::UnparserError = JSON::GeneratorError
1528
+
1529
+ module Kernel
1530
+ private
1531
+
1532
+ # If _object_ is string-like, parse the string and return the parsed result as
1533
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
1534
+ # structure object and return it.
1535
+ #
1536
+ # The _opts_ argument is passed through to generate/parse respectively. See
1537
+ # generate and parse for their documentation.
1538
+ #
1539
+ # source://json//json/common.rb#679
1540
+ def JSON(object, *args); end
1541
+
1542
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1543
+ # one line.
1544
+ #
1545
+ # source://json//json/common.rb#657
1546
+ def j(*objs); end
1547
+
1548
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1549
+ # indentation and over many lines.
1550
+ #
1551
+ # source://json//json/common.rb#666
1552
+ def jj(*objs); end
1553
+ end