repeatable 1.1.0 → 1.2.1

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