e621_export_downloader 0.0.1

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