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