optimistic-json 0.1.1 → 0.1.3

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