rails_type_id 0.1.0

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