m2m_keygen 0.4.7 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/.overcommit.yml +4 -7
  3. data/.rubocop.yml +19 -16
  4. data/.ruby-version +1 -1
  5. data/.streerc +1 -0
  6. data/.tool-versions +1 -0
  7. data/CHANGELOG.md +73 -1
  8. data/Gemfile +2 -2
  9. data/Gemfile.lock +138 -160
  10. data/README.md +64 -78
  11. data/docs/MIGRATING.md +69 -0
  12. data/docs/SPEC.md +245 -0
  13. data/examples/nonce_store/postgres.rb +40 -0
  14. data/examples/nonce_store/redis.rb +23 -0
  15. data/gemfiles/rack_2.gemfile +5 -0
  16. data/gemfiles/rack_3.gemfile +5 -0
  17. data/lib/m2m_keygen/canonicalizer.rb +57 -0
  18. data/lib/m2m_keygen/nonce_store/disabled.rb +19 -0
  19. data/lib/m2m_keygen/nonce_store/memory.rb +64 -0
  20. data/lib/m2m_keygen/nonce_store.rb +18 -0
  21. data/lib/m2m_keygen/rack_validator.rb +72 -19
  22. data/lib/m2m_keygen/request_signer/signed_request.rb +10 -0
  23. data/lib/m2m_keygen/request_signer.rb +118 -0
  24. data/lib/m2m_keygen/signature.rb +41 -39
  25. data/lib/m2m_keygen/types/params_type.rb +6 -16
  26. data/lib/m2m_keygen/version.rb +1 -1
  27. data/lib/m2m_keygen.rb +6 -0
  28. data/m2m_keygen.gemspec +12 -14
  29. data/sorbet/config +1 -0
  30. data/sorbet/rbi/gems/.gitattributes +1 -0
  31. data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +45 -79
  32. data/sorbet/rbi/gems/{benchmark@0.2.0.rbi → benchmark@0.5.0.rbi} +91 -58
  33. data/sorbet/rbi/gems/bundler-audit@0.9.3.rbi +397 -0
  34. data/sorbet/rbi/gems/byebug@13.0.0.rbi +3651 -0
  35. data/sorbet/rbi/gems/childprocess@5.1.0.rbi +336 -0
  36. data/sorbet/rbi/gems/concurrent-ruby@1.3.7.rbi +384 -0
  37. data/sorbet/rbi/gems/{diff-lcs@1.5.0.rbi → diff-lcs@1.6.2.rbi} +189 -199
  38. data/sorbet/rbi/gems/{docile@1.4.0.rbi → docile@1.4.1.rbi} +147 -147
  39. data/sorbet/rbi/gems/dotenv@3.2.0.rbi +267 -0
  40. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  41. data/sorbet/rbi/gems/{faker@2.22.0.rbi → faker@3.8.0.rbi} +8468 -3829
  42. data/sorbet/rbi/gems/{ffi@1.15.5.rbi → ffi@1.17.4.rbi} +1 -0
  43. data/sorbet/rbi/gems/{formatador@1.1.0.rbi → formatador@1.2.3.rbi} +1 -0
  44. data/sorbet/rbi/gems/{guard@2.18.0.rbi → guard@2.20.1.rbi} +1 -0
  45. data/sorbet/rbi/gems/{i18n@1.12.0.rbi → i18n@1.15.2.rbi} +687 -827
  46. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  47. data/sorbet/rbi/gems/{json@2.6.2.rbi → json@2.20.0.rbi} +994 -252
  48. data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
  49. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  50. data/sorbet/rbi/gems/listen@3.10.0.rbi +9 -0
  51. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  52. data/sorbet/rbi/gems/{lumberjack@1.2.8.rbi → lumberjack@1.4.2.rbi} +1 -0
  53. data/sorbet/rbi/gems/{method_source@1.0.0.rbi → method_source@1.1.0.rbi} +111 -90
  54. data/sorbet/rbi/gems/{overcommit@0.59.1.rbi → overcommit@0.71.0.rbi} +503 -647
  55. data/sorbet/rbi/gems/parallel@2.1.0.rbi +321 -0
  56. data/sorbet/rbi/gems/parser@3.3.11.1.rbi +5229 -0
  57. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +878 -0
  58. data/sorbet/rbi/gems/prism@1.9.0.rbi +42224 -0
  59. data/sorbet/rbi/gems/pry-byebug@3.12.0.rbi +481 -0
  60. data/sorbet/rbi/gems/{pry@0.14.1.rbi → pry@0.16.0.rbi} +2567 -3550
  61. data/sorbet/rbi/gems/{racc@1.6.0.rbi → racc@1.8.1.rbi} +54 -40
  62. data/sorbet/rbi/gems/rack@3.2.6.rbi +4653 -0
  63. data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.4.2.rbi} +963 -732
  64. data/sorbet/rbi/gems/{rb-inotify@0.10.1.rbi → rb-inotify@0.11.1.rbi} +1 -0
  65. data/sorbet/rbi/gems/rbi@0.3.14.rbi +5519 -0
  66. data/sorbet/rbi/gems/rbs@4.0.3.rbi +6908 -0
  67. data/sorbet/rbi/gems/regexp_parser@2.12.0.rbi +3398 -0
  68. data/sorbet/rbi/gems/reline@0.6.3.rbi +2446 -0
  69. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  70. data/sorbet/rbi/gems/{rexml@3.2.5.rbi → rexml@3.4.4.rbi} +1085 -894
  71. data/sorbet/rbi/gems/rspec-core@3.13.6.rbi +9475 -0
  72. data/sorbet/rbi/gems/rspec-expectations@3.13.5.rbi +6108 -0
  73. data/sorbet/rbi/gems/rspec-mocks@3.13.8.rbi +4787 -0
  74. data/sorbet/rbi/gems/rspec-support@3.13.7.rbi +1274 -0
  75. data/sorbet/rbi/gems/rspec@3.13.2.rbi +15 -0
  76. data/sorbet/rbi/gems/rspec_in_context@1.2.2.rbi +294 -0
  77. data/sorbet/rbi/gems/rubocop-ast@1.49.1.rbi +7140 -0
  78. data/sorbet/rbi/gems/rubocop-faker@1.3.0.rbi +88 -0
  79. data/sorbet/rbi/gems/rubocop-performance@1.26.1.rbi +3403 -0
  80. data/sorbet/rbi/gems/rubocop-sorbet@0.12.0.rbi +2448 -0
  81. data/sorbet/rbi/gems/rubocop@1.88.1.rbi +63103 -0
  82. data/sorbet/rbi/gems/ruby-lsp@0.26.9.rbi +28 -0
  83. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  84. data/sorbet/rbi/gems/rubydex@0.2.7.rbi +836 -0
  85. data/sorbet/rbi/gems/simplecov-html@0.13.2.rbi +90 -0
  86. data/sorbet/rbi/gems/{simplecov@0.21.2.rbi → simplecov@0.22.0.rbi} +438 -578
  87. data/sorbet/rbi/gems/spoom@1.8.2.rbi +6691 -0
  88. data/sorbet/rbi/gems/syntax_tree@6.3.0.rbi +22090 -0
  89. data/sorbet/rbi/gems/tapioca@0.19.2.rbi +3597 -0
  90. data/sorbet/rbi/gems/{thor@1.2.1.rbi → thor@1.5.0.rbi} +1085 -1171
  91. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  92. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
  93. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
  94. data/sorbet/rbi/gems/{yard-sorbet@0.7.0.rbi → yard-sorbet@0.9.0.rbi} +142 -99
  95. data/sorbet/rbi/gems/{yard@0.9.28.rbi → yard@0.9.44.rbi} +5350 -6316
  96. data/sorbet/rbi/gems/zeitwerk@2.8.2.rbi +1178 -0
  97. metadata +106 -111
  98. data/.prettierrc.js +0 -4
  99. data/docs/M2mKeygen/Error.html +0 -135
  100. data/docs/M2mKeygen/ParamsEncoder.html +0 -321
  101. data/docs/M2mKeygen/RackValidator.html +0 -533
  102. data/docs/M2mKeygen/Signature.html +0 -680
  103. data/docs/M2mKeygen/Types.html +0 -147
  104. data/docs/M2mKeygen.html +0 -157
  105. data/docs/_index.html +0 -182
  106. data/docs/class_list.html +0 -51
  107. data/docs/css/common.css +0 -1
  108. data/docs/css/full_list.css +0 -58
  109. data/docs/css/style.css +0 -497
  110. data/docs/file.README.html +0 -230
  111. data/docs/file_list.html +0 -56
  112. data/docs/frames.html +0 -17
  113. data/docs/index.html +0 -230
  114. data/docs/js/app.js +0 -314
  115. data/docs/js/full_list.js +0 -216
  116. data/docs/js/jquery.js +0 -4
  117. data/docs/method_list.html +0 -139
  118. data/docs/top-level-namespace.html +0 -110
  119. data/lib/m2m_keygen/params_encoder.rb +0 -56
  120. data/package.json +0 -12
  121. data/sig/m2m_keygen.rbs +0 -4
  122. data/sorbet/rbi/gems/activesupport@7.0.3.1.rbi +0 -18608
  123. data/sorbet/rbi/gems/backport@1.2.0.rbi +0 -522
  124. data/sorbet/rbi/gems/bundler-audit@0.9.1.rbi +0 -308
  125. data/sorbet/rbi/gems/byebug@11.1.3.rbi +0 -3603
  126. data/sorbet/rbi/gems/childprocess@4.1.0.rbi +0 -401
  127. data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +0 -11581
  128. data/sorbet/rbi/gems/dotenv@2.8.1.rbi +0 -234
  129. data/sorbet/rbi/gems/e2mmap@0.1.0.rbi +0 -8
  130. data/sorbet/rbi/gems/haml@5.2.2.rbi +0 -3190
  131. data/sorbet/rbi/gems/jaro_winkler@1.5.4.rbi +0 -19
  132. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +0 -133
  133. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +0 -3261
  134. data/sorbet/rbi/gems/listen@3.7.1.rbi +0 -1181
  135. data/sorbet/rbi/gems/minitest@5.16.3.rbi +0 -1459
  136. data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +0 -6514
  137. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -277
  138. data/sorbet/rbi/gems/parser@3.1.2.1.rbi +0 -6826
  139. data/sorbet/rbi/gems/prettier@3.2.0.rbi +0 -22
  140. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +0 -8
  141. data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +0 -1222
  142. data/sorbet/rbi/gems/rack@2.2.4.rbi +0 -5630
  143. data/sorbet/rbi/gems/rbi@0.0.15.rbi +0 -3007
  144. data/sorbet/rbi/gems/rbs@2.6.0.rbi +0 -8
  145. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -3366
  146. data/sorbet/rbi/gems/reverse_markdown@2.1.1.rbi +0 -389
  147. data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +0 -10786
  148. data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +0 -8170
  149. data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +0 -5385
  150. data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +0 -1746
  151. data/sorbet/rbi/gems/rspec@3.11.0.rbi +0 -187
  152. data/sorbet/rbi/gems/rspec_in_context@1.1.0.3.rbi +0 -1113
  153. data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +0 -7044
  154. data/sorbet/rbi/gems/rubocop-faker@1.1.0.rbi +0 -106
  155. data/sorbet/rbi/gems/rubocop-performance@1.14.3.rbi +0 -2982
  156. data/sorbet/rbi/gems/rubocop-sorbet@0.6.11.rbi +0 -990
  157. data/sorbet/rbi/gems/rubocop@1.35.1.rbi +0 -52002
  158. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -1239
  159. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -219
  160. data/sorbet/rbi/gems/solargraph@0.46.0.rbi +0 -9075
  161. data/sorbet/rbi/gems/spoom@1.1.12.rbi +0 -2369
  162. data/sorbet/rbi/gems/syntax_tree-haml@1.3.1.rbi +0 -8
  163. data/sorbet/rbi/gems/syntax_tree-rbs@0.5.0.rbi +0 -8
  164. data/sorbet/rbi/gems/syntax_tree@3.5.0.rbi +0 -8
  165. data/sorbet/rbi/gems/tapioca@0.9.4.rbi +0 -2946
  166. data/sorbet/rbi/gems/temple@0.8.2.rbi +0 -1712
  167. data/sorbet/rbi/gems/tilt@2.0.11.rbi +0 -742
  168. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +0 -5914
  169. data/sorbet/rbi/gems/unicode-display_width@2.2.0.rbi +0 -48
  170. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -4529
  171. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -2553
  172. data/sorbet/rbi/gems/zeitwerk@2.6.0.rbi +0 -867
  173. data/sorbet/rbi/manual.rbi +0 -7
  174. data/yarn.lock +0 -20
@@ -1,28 +1,23 @@
1
- # typed: true
1
+ # typed: false
2
2
 
3
3
  # DO NOT EDIT MANUALLY
4
4
  # This is an autogenerated file for types exported from the `json` gem.
5
5
  # Please instead update this file by running `bin/tapioca gem json`.
6
6
 
7
- # Extends any Class to include _json_creatable?_ method.
8
- #
9
- # source://json-2.6.2/lib/json/common.rb:695
10
- class Class < ::Module
11
- # Returns true if this class can be used to create an instance
12
- # from a serialised JSON string. The class has to implement a class
13
- # method _json_create_ that expects a hash as first parameter. The hash
14
- # should include the required data.
15
- #
16
- # @return [Boolean]
17
- #
18
- # source://json-2.6.2/lib/json/common.rb:700
19
- def json_creatable?; end
20
- end
21
7
 
22
8
  # = JavaScript \Object Notation (\JSON)
23
9
  #
24
10
  # \JSON is a lightweight data-interchange format.
25
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
+ #
26
21
  # A \JSON value is one of the following:
27
22
  # - Double-quoted text: <tt>"foo"</tt>.
28
23
  # - Number: +1+, +1.0+, +2.0e2+.
@@ -144,6 +139,24 @@ end
144
139
  #
145
140
  # ---
146
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
+ #
147
160
  # Option +allow_nan+ (boolean) specifies whether to allow
148
161
  # NaN, Infinity, and MinusInfinity in +source+;
149
162
  # defaults to +false+.
@@ -160,8 +173,61 @@ end
160
173
  # ruby = JSON.parse(source, {allow_nan: true})
161
174
  # ruby # => [NaN, Infinity, -Infinity]
162
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_comments+ (boolean) specifies whether to allow
191
+ # JavaScript style comments (either <tt>// comment</tt> or <tt>/* comment */</tt>);
192
+ # defaults to +false+.
193
+ #
194
+ # When not specified, a deprecation warning is emitted if a comment is encountered.
195
+ #
196
+ # When set to +true+, comments are ignored:
197
+ # JSON.parse('/* comment */ {"a": 1, "a":2}') # => {"a" => 2}
198
+ #
199
+ # When set to +false+, the future default:
200
+ # JSON.parse('/* comment */ {"a": 1, "a":2}') # unexpected character: '/' at line 1 column 1 (JSON::ParserError)
201
+ #
202
+ # ---
203
+ #
204
+ # Option +allow_control_characters+ (boolean) specifies whether to allow
205
+ # unescaped ASCII control characters, such as newlines, in strings;
206
+ # defaults to +false+.
207
+ #
208
+ # With the default, +false+:
209
+ # JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
210
+ #
211
+ # When enabled:
212
+ # JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
213
+ #
214
+ # ---
215
+ #
216
+ # Option +allow_invalid_escape+ (boolean) specifies whether to ignore backslahes that are followed
217
+ # by an invalid escape character in strings;
218
+ # defaults to +false+.
219
+ #
220
+ # With the default, +false+:
221
+ # JSON.parse('"Hell\o"') # invalid escape character in string (JSON::ParserError)
222
+ #
223
+ # When enabled:
224
+ # JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello"
225
+ #
163
226
  # ====== Output Options
164
227
  #
228
+ # Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
229
+ # defaults to +false+.
230
+ #
165
231
  # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
166
232
  # should be Symbols;
167
233
  # defaults to +false+ (use Strings).
@@ -286,8 +352,27 @@ end
286
352
  # JSON.generate(JSON::MinusInfinity)
287
353
  #
288
354
  # Allow:
289
- # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
290
- # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
355
+ # ruby = [Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity]
356
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,NaN,Infinity,-Infinity]'
357
+ #
358
+ # ---
359
+ #
360
+ # Option +allow_duplicate_key+ (boolean) specifies whether
361
+ # hashes with duplicate keys should be allowed or produce an error.
362
+ # defaults to emit a deprecation warning.
363
+ #
364
+ # With the default, (not set):
365
+ # Warning[:deprecated] = true
366
+ # JSON.generate({ foo: 1, "foo" => 2 })
367
+ # # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
368
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
369
+ # # => '{"foo":1,"foo":2}'
370
+ #
371
+ # With <tt>false</tt>
372
+ # JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
373
+ # # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
374
+ #
375
+ # In version 3.0, <tt>false</tt> will become the default.
291
376
  #
292
377
  # ---
293
378
  #
@@ -302,6 +387,15 @@ end
302
387
  # # Raises JSON::NestingError (nesting of 2 is too deep):
303
388
  # JSON.generate(obj, max_nesting: 2)
304
389
  #
390
+ # ====== Escaping Options
391
+ #
392
+ # Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
393
+ # and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
394
+ # tags.
395
+ #
396
+ # Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
397
+ # should be escaped.
398
+ #
305
399
  # ====== Output Options
306
400
  #
307
401
  # The default formatting options generate the most compact
@@ -359,6 +453,9 @@ end
359
453
  #
360
454
  # == \JSON Additions
361
455
  #
456
+ # Note that JSON Additions must only be used with trusted data, and is
457
+ # deprecated.
458
+ #
362
459
  # When you "round trip" a non-\String object from Ruby to \JSON and back,
363
460
  # you have a new \String, instead of the object you began with:
364
461
  # ruby0 = Range.new(0, 2)
@@ -386,13 +483,13 @@ end
386
483
  # json1 = JSON.generate(ruby)
387
484
  # ruby1 = JSON.parse(json1, create_additions: true)
388
485
  # # Make a nice display.
389
- # display = <<EOT
390
- # Generated JSON:
391
- # Without addition: #{json0} (#{json0.class})
392
- # With addition: #{json1} (#{json1.class})
393
- # Parsed JSON:
394
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
395
- # With addition: #{ruby1.inspect} (#{ruby1.class})
486
+ # display = <<~EOT
487
+ # Generated JSON:
488
+ # Without addition: #{json0} (#{json0.class})
489
+ # With addition: #{json1} (#{json1.class})
490
+ # Parsed JSON:
491
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
492
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
396
493
  # EOT
397
494
  # puts display
398
495
  #
@@ -570,13 +667,13 @@ end
570
667
  # json1 = JSON.generate(foo1)
571
668
  # obj1 = JSON.parse(json1, create_additions: true)
572
669
  # # Make a nice display.
573
- # display = <<EOT
574
- # Generated JSON:
575
- # Without custom addition: #{json0} (#{json0.class})
576
- # With custom addition: #{json1} (#{json1.class})
577
- # Parsed JSON:
578
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
579
- # With custom addition: #{obj1.inspect} (#{obj1.class})
670
+ # display = <<~EOT
671
+ # Generated JSON:
672
+ # Without custom addition: #{json0} (#{json0.class})
673
+ # With custom addition: #{json1} (#{json1.class})
674
+ # Parsed JSON:
675
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
676
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
580
677
  # EOT
581
678
  # puts display
582
679
  #
@@ -589,7 +686,7 @@ end
589
686
  # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
590
687
  # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
591
688
  #
592
- # source://json-2.6.2/lib/json/version.rb:2
689
+ # pkg:gem/json#lib/json/version.rb:3
593
690
  module JSON
594
691
  private
595
692
 
@@ -621,8 +718,8 @@ module JSON
621
718
  # Output:
622
719
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
623
720
  #
624
- # source://json-2.6.2/lib/json/common.rb:631
625
- def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
721
+ # pkg:gem/json#lib/json/common.rb:932
722
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
626
723
 
627
724
  # :call-seq:
628
725
  # JSON.fast_generate(obj, opts) -> new_string
@@ -638,21 +735,18 @@ module JSON
638
735
  # # Raises SystemStackError (stack level too deep):
639
736
  # JSON.fast_generate(a)
640
737
  #
641
- # source://json-2.6.2/lib/json/common.rb:335
738
+ # pkg:gem/json#lib/json/common.rb:462
642
739
  def fast_generate(obj, opts = T.unsafe(nil)); end
643
740
 
644
- # :stopdoc:
645
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
646
- #
647
- # source://json-2.6.2/lib/json/common.rb:335
648
- def fast_unparse(obj, opts = T.unsafe(nil)); end
741
+ # pkg:gem/json#lib/json/common.rb:977
742
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
649
743
 
650
744
  # :call-seq:
651
745
  # JSON.generate(obj, opts = nil) -> new_string
652
746
  #
653
747
  # Returns a \String containing the generated \JSON data.
654
748
  #
655
- # See also JSON.fast_generate, JSON.pretty_generate.
749
+ # See also JSON.pretty_generate.
656
750
  #
657
751
  # Argument +obj+ is the Ruby object to be converted to \JSON.
658
752
  #
@@ -683,14 +777,25 @@ module JSON
683
777
  # # Raises JSON::NestingError (nesting of 100 is too deep):
684
778
  # JSON.generate(a)
685
779
  #
686
- # source://json-2.6.2/lib/json/common.rb:296
780
+ # pkg:gem/json#lib/json/common.rb:441
687
781
  def generate(obj, opts = T.unsafe(nil)); end
688
782
 
689
783
  # :call-seq:
784
+ # JSON.load(source, options = {}) -> object
690
785
  # JSON.load(source, proc = nil, options = {}) -> object
691
786
  #
692
787
  # Returns the Ruby objects created by parsing the given +source+.
693
788
  #
789
+ # BEWARE: This method is meant to serialise data from trusted user input,
790
+ # like from your own database server or clients under your control, it could
791
+ # be dangerous to allow untrusted users to pass JSON sources into it.
792
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
793
+ #
794
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
795
+ # non native type is deserialized, without `create_additions` being explicitly
796
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
797
+ # by default.
798
+ #
694
799
  # - Argument +source+ must be, or be convertible to, a \String:
695
800
  # - If +source+ responds to instance method +to_str+,
696
801
  # <tt>source.to_str</tt> becomes the source.
@@ -705,9 +810,6 @@ module JSON
705
810
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
706
811
  # It will be called recursively with each result (depth-first order).
707
812
  # See details below.
708
- # BEWARE: This method is meant to serialise data from trusted user input,
709
- # like from your own database server or clients under your control, it could
710
- # be dangerous to allow untrusted users to pass JSON sources into it.
711
813
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
712
814
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
713
815
  # The default options can be changed via method JSON.load_default_options=.
@@ -718,17 +820,17 @@ module JSON
718
820
  # <tt>parse(source, opts)</tt>; see #parse.
719
821
  #
720
822
  # Source for following examples:
721
- # source = <<-EOT
722
- # {
723
- # "name": "Dave",
724
- # "age" :40,
725
- # "hats": [
726
- # "Cattleman's",
727
- # "Panama",
728
- # "Tophat"
729
- # ]
730
- # }
731
- # EOT
823
+ # source = <<~JSON
824
+ # {
825
+ # "name": "Dave",
826
+ # "age" :40,
827
+ # "hats": [
828
+ # "Cattleman's",
829
+ # "Panama",
830
+ # "Tophat"
831
+ # ]
832
+ # }
833
+ # JSON
732
834
  #
733
835
  # Load a \String:
734
836
  # ruby = JSON.load(source)
@@ -793,6 +895,7 @@ module JSON
793
895
  # when Array
794
896
  # obj.map! {|v| deserialize_obj v }
795
897
  # end
898
+ # obj
796
899
  # })
797
900
  # pp ruby
798
901
  # Output:
@@ -814,7 +917,7 @@ module JSON
814
917
  # #<Admin:0x00000000064c41f8
815
918
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
816
919
  #
817
- # source://json-2.6.2/lib/json/common.rb:557
920
+ # pkg:gem/json#lib/json/common.rb:856
818
921
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
819
922
 
820
923
  # :call-seq:
@@ -825,7 +928,7 @@ module JSON
825
928
  #
826
929
  # See method #parse.
827
930
  #
828
- # source://json-2.6.2/lib/json/common.rb:245
931
+ # pkg:gem/json#lib/json/common.rb:390
829
932
  def load_file(filespec, opts = T.unsafe(nil)); end
830
933
 
831
934
  # :call-seq:
@@ -836,7 +939,7 @@ module JSON
836
939
  #
837
940
  # See method #parse!
838
941
  #
839
- # source://json-2.6.2/lib/json/common.rb:256
942
+ # pkg:gem/json#lib/json/common.rb:401
840
943
  def load_file!(filespec, opts = T.unsafe(nil)); end
841
944
 
842
945
  # :call-seq:
@@ -867,17 +970,17 @@ module JSON
867
970
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
868
971
  #
869
972
  # Parses nested JSON objects:
870
- # source = <<-EOT
871
- # {
872
- # "name": "Dave",
873
- # "age" :40,
874
- # "hats": [
875
- # "Cattleman's",
876
- # "Panama",
877
- # "Tophat"
878
- # ]
879
- # }
880
- # EOT
973
+ # source = <<~JSON
974
+ # {
975
+ # "name": "Dave",
976
+ # "age" :40,
977
+ # "hats": [
978
+ # "Cattleman's",
979
+ # "Panama",
980
+ # "Tophat"
981
+ # ]
982
+ # }
983
+ # JSON
881
984
  # ruby = JSON.parse(source)
882
985
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
883
986
  #
@@ -887,7 +990,7 @@ module JSON
887
990
  # # Raises JSON::ParserError (783: unexpected token at ''):
888
991
  # JSON.parse('')
889
992
  #
890
- # source://json-2.6.2/lib/json/common.rb:215
993
+ # pkg:gem/json#lib/json/common.rb:353
891
994
  def parse(source, opts = T.unsafe(nil)); end
892
995
 
893
996
  # :call-seq:
@@ -902,7 +1005,7 @@ module JSON
902
1005
  # which disables checking for nesting depth.
903
1006
  # - Option +allow_nan+, if not provided, defaults to +true+.
904
1007
  #
905
- # source://json-2.6.2/lib/json/common.rb:230
1008
+ # pkg:gem/json#lib/json/common.rb:375
906
1009
  def parse!(source, opts = T.unsafe(nil)); end
907
1010
 
908
1011
  # :call-seq:
@@ -935,29 +1038,155 @@ module JSON
935
1038
  # }
936
1039
  # }
937
1040
  #
938
- # source://json-2.6.2/lib/json/common.rb:390
1041
+ # pkg:gem/json#lib/json/common.rb:509
939
1042
  def pretty_generate(obj, opts = T.unsafe(nil)); end
940
1043
 
1044
+ # pkg:gem/json#lib/json/common.rb:987
1045
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1046
+
1047
+ # pkg:gem/json#lib/json/common.rb:997
1048
+ def restore(*_arg0, **_arg1, &_arg2); end
1049
+
941
1050
  # :stopdoc:
942
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1051
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1052
+ # so usage still exist in the wild.
943
1053
  #
944
- # source://json-2.6.2/lib/json/common.rb:390
945
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
1054
+ # pkg:gem/json#lib/json/common.rb:967
1055
+ def unparse(*_arg0, **_arg1, &_arg2); end
946
1056
 
947
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1057
+ # :call-seq:
1058
+ # JSON.unsafe_load(source, options = {}) -> object
1059
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
948
1060
  #
949
- # source://json-2.6.2/lib/json/common.rb:575
950
- def recurse_proc(result, &proc); end
951
-
952
- # source://json-2.6.2/lib/json/common.rb:557
953
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
954
-
955
- # :stopdoc:
956
- # I want to deprecate these later, so I'll first be silent about them, and
957
- # later delete them.
1061
+ # Returns the Ruby objects created by parsing the given +source+.
1062
+ #
1063
+ # BEWARE: This method is meant to serialise data from trusted user input,
1064
+ # like from your own database server or clients under your control, it could
1065
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1066
+ #
1067
+ # - Argument +source+ must be, or be convertible to, a \String:
1068
+ # - If +source+ responds to instance method +to_str+,
1069
+ # <tt>source.to_str</tt> becomes the source.
1070
+ # - If +source+ responds to instance method +to_io+,
1071
+ # <tt>source.to_io.read</tt> becomes the source.
1072
+ # - If +source+ responds to instance method +read+,
1073
+ # <tt>source.read</tt> becomes the source.
1074
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1075
+ # - Option +allow_blank+ specifies a truthy value.
1076
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1077
+ # - Otherwise, +source+ remains the source.
1078
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1079
+ # It will be called recursively with each result (depth-first order).
1080
+ # See details below.
1081
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1082
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1083
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1084
+ #
1085
+ # ---
1086
+ #
1087
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1088
+ # <tt>parse(source, opts)</tt>; see #parse.
1089
+ #
1090
+ # Source for following examples:
1091
+ # source = <<~JSON
1092
+ # {
1093
+ # "name": "Dave",
1094
+ # "age" :40,
1095
+ # "hats": [
1096
+ # "Cattleman's",
1097
+ # "Panama",
1098
+ # "Tophat"
1099
+ # ]
1100
+ # }
1101
+ # JSON
1102
+ #
1103
+ # Load a \String:
1104
+ # ruby = JSON.unsafe_load(source)
1105
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1106
+ #
1107
+ # Load an \IO object:
1108
+ # require 'stringio'
1109
+ # object = JSON.unsafe_load(StringIO.new(source))
1110
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1111
+ #
1112
+ # Load a \File object:
1113
+ # path = 't.json'
1114
+ # File.write(path, source)
1115
+ # File.open(path) do |file|
1116
+ # JSON.unsafe_load(file)
1117
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1118
+ #
1119
+ # ---
1120
+ #
1121
+ # When +proc+ is given:
1122
+ # - Modifies +source+ as above.
1123
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1124
+ # - Recursively calls <tt>proc(result)</tt>.
1125
+ # - Returns the final result.
1126
+ #
1127
+ # Example:
1128
+ # require 'json'
1129
+ #
1130
+ # # Some classes for the example.
1131
+ # class Base
1132
+ # def initialize(attributes)
1133
+ # @attributes = attributes
1134
+ # end
1135
+ # end
1136
+ # class User < Base; end
1137
+ # class Account < Base; end
1138
+ # class Admin < Base; end
1139
+ # # The JSON source.
1140
+ # json = <<-EOF
1141
+ # {
1142
+ # "users": [
1143
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1144
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1145
+ # ],
1146
+ # "accounts": [
1147
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1148
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1149
+ # ],
1150
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1151
+ # }
1152
+ # EOF
1153
+ # # Deserializer method.
1154
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1155
+ # type = obj.is_a?(Hash) && obj["type"]
1156
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1157
+ # end
1158
+ # # Call to JSON.unsafe_load
1159
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1160
+ # case obj
1161
+ # when Hash
1162
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1163
+ # when Array
1164
+ # obj.map! {|v| deserialize_obj v }
1165
+ # end
1166
+ # obj
1167
+ # })
1168
+ # pp ruby
1169
+ # Output:
1170
+ # {"users"=>
1171
+ # [#<User:0x00000000064c4c98
1172
+ # @attributes=
1173
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1174
+ # #<User:0x00000000064c4bd0
1175
+ # @attributes=
1176
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1177
+ # "accounts"=>
1178
+ # [{"account"=>
1179
+ # #<Account:0x00000000064c4928
1180
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1181
+ # {"account"=>
1182
+ # #<Account:0x00000000064c4680
1183
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1184
+ # "admins"=>
1185
+ # #<Admin:0x00000000064c41f8
1186
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
958
1187
  #
959
- # source://json-2.6.2/lib/json/common.rb:296
960
- def unparse(obj, opts = T.unsafe(nil)); end
1188
+ # pkg:gem/json#lib/json/common.rb:685
1189
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
961
1190
 
962
1191
  class << self
963
1192
  # :call-seq:
@@ -972,35 +1201,33 @@ module JSON
972
1201
  # ruby = [0, 1, nil]
973
1202
  # JSON[ruby] # => '[0,1,null]'
974
1203
  #
975
- # source://json-2.6.2/lib/json/common.rb:18
1204
+ # pkg:gem/json#lib/json/common.rb:132
976
1205
  def [](object, opts = T.unsafe(nil)); end
977
1206
 
978
- # source://json-2.6.2/lib/json/common.rb:81
979
- def create_fast_state; end
1207
+ # pkg:gem/json#lib/json/common.rb:208
1208
+ def _dump_default_options; end
1209
+
1210
+ # pkg:gem/json#lib/json/common.rb:208
1211
+ def _load_default_options; end
1212
+
1213
+ # pkg:gem/json#lib/json/common.rb:208
1214
+ def _unsafe_load_default_options; end
980
1215
 
981
1216
  # Returns the current create identifier.
982
1217
  # See also JSON.create_id=.
983
1218
  #
984
- # source://json-2.6.2/lib/json/common.rb:126
1219
+ # pkg:gem/json#lib/json/common.rb:236
985
1220
  def create_id; end
986
1221
 
987
1222
  # Sets create identifier, which is used to decide if the _json_create_
988
1223
  # hook of a class should be called; initial value is +json_class+:
989
1224
  # JSON.create_id # => 'json_class'
990
1225
  #
991
- # source://json-2.6.2/lib/json/common.rb:120
1226
+ # pkg:gem/json#lib/json/common.rb:230
992
1227
  def create_id=(new_value); end
993
1228
 
994
- # source://json-2.6.2/lib/json/common.rb:91
995
- def create_pretty_state; end
996
-
997
- # Return the constant located at _path_. The format of _path_ has to be
998
- # either ::A::B::C or A::B::C. In any case, A has to be located at the top
999
- # level (absolute namespace path?). If there doesn't exist a constant at
1000
- # the given path, an ArgumentError is raised.
1001
- #
1002
- # source://json-2.6.2/lib/json/common.rb:42
1003
- def deep_const_get(path); end
1229
+ # pkg:gem/json#lib/json/common.rb:104
1230
+ def deprecation_warning(message, uplevel = T.unsafe(nil)); end
1004
1231
 
1005
1232
  # :call-seq:
1006
1233
  # JSON.dump(obj, io = nil, limit = nil)
@@ -1030,24 +1257,14 @@ module JSON
1030
1257
  # Output:
1031
1258
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1032
1259
  #
1033
- # source://json-2.6.2/lib/json/common.rb:631
1034
- def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
1260
+ # pkg:gem/json#lib/json/common.rb:932
1261
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1035
1262
 
1036
- # Sets or returns the default options for the JSON.dump method.
1037
- # Initially:
1038
- # opts = JSON.dump_default_options
1039
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
1040
- #
1041
- # source://json-2.6.2/lib/json/common.rb:596
1263
+ # pkg:gem/json#lib/json/common.rb:208
1042
1264
  def dump_default_options; end
1043
1265
 
1044
- # Sets or returns the default options for the JSON.dump method.
1045
- # Initially:
1046
- # opts = JSON.dump_default_options
1047
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
1048
- #
1049
- # source://json-2.6.2/lib/json/common.rb:596
1050
- def dump_default_options=(_arg0); end
1266
+ # pkg:gem/json#lib/json/common.rb:208
1267
+ def dump_default_options=(val); end
1051
1268
 
1052
1269
  # :call-seq:
1053
1270
  # JSON.fast_generate(obj, opts) -> new_string
@@ -1063,21 +1280,18 @@ module JSON
1063
1280
  # # Raises SystemStackError (stack level too deep):
1064
1281
  # JSON.fast_generate(a)
1065
1282
  #
1066
- # source://json-2.6.2/lib/json/common.rb:335
1283
+ # pkg:gem/json#lib/json/common.rb:462
1067
1284
  def fast_generate(obj, opts = T.unsafe(nil)); end
1068
1285
 
1069
- # :stopdoc:
1070
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1071
- #
1072
- # source://json-2.6.2/lib/json/common.rb:335
1073
- def fast_unparse(obj, opts = T.unsafe(nil)); end
1286
+ # pkg:gem/json#lib/json/common.rb:977
1287
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
1074
1288
 
1075
1289
  # :call-seq:
1076
1290
  # JSON.generate(obj, opts = nil) -> new_string
1077
1291
  #
1078
1292
  # Returns a \String containing the generated \JSON data.
1079
1293
  #
1080
- # See also JSON.fast_generate, JSON.pretty_generate.
1294
+ # See also JSON.pretty_generate.
1081
1295
  #
1082
1296
  # Argument +obj+ is the Ruby object to be converted to \JSON.
1083
1297
  #
@@ -1108,31 +1322,35 @@ module JSON
1108
1322
  # # Raises JSON::NestingError (nesting of 100 is too deep):
1109
1323
  # JSON.generate(a)
1110
1324
  #
1111
- # source://json-2.6.2/lib/json/common.rb:296
1325
+ # pkg:gem/json#lib/json/common.rb:441
1112
1326
  def generate(obj, opts = T.unsafe(nil)); end
1113
1327
 
1114
- # Returns the JSON generator module that is used by JSON. This is
1115
- # either JSON::Ext::Generator or JSON::Pure::Generator:
1116
- # JSON.generator # => JSON::Ext::Generator
1328
+ # Returns the JSON generator module that is used by JSON.
1117
1329
  #
1118
- # source://json-2.6.2/lib/json/common.rb:103
1330
+ # pkg:gem/json#lib/json/common.rb:179
1119
1331
  def generator; end
1120
1332
 
1121
1333
  # Set the module _generator_ to be used by JSON.
1122
1334
  #
1123
- # source://json-2.6.2/lib/json/common.rb:58
1335
+ # pkg:gem/json#lib/json/common.rb:156
1124
1336
  def generator=(generator); end
1125
1337
 
1126
- # Encodes string using String.encode.
1127
- #
1128
- # source://json-2.6.2/lib/json/common.rb:653
1129
- def iconv(to, from, string); end
1130
-
1131
1338
  # :call-seq:
1339
+ # JSON.load(source, options = {}) -> object
1132
1340
  # JSON.load(source, proc = nil, options = {}) -> object
1133
1341
  #
1134
1342
  # Returns the Ruby objects created by parsing the given +source+.
1135
1343
  #
1344
+ # BEWARE: This method is meant to serialise data from trusted user input,
1345
+ # like from your own database server or clients under your control, it could
1346
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1347
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
1348
+ #
1349
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
1350
+ # non native type is deserialized, without `create_additions` being explicitly
1351
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
1352
+ # by default.
1353
+ #
1136
1354
  # - Argument +source+ must be, or be convertible to, a \String:
1137
1355
  # - If +source+ responds to instance method +to_str+,
1138
1356
  # <tt>source.to_str</tt> becomes the source.
@@ -1147,9 +1365,6 @@ module JSON
1147
1365
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1148
1366
  # It will be called recursively with each result (depth-first order).
1149
1367
  # See details below.
1150
- # BEWARE: This method is meant to serialise data from trusted user input,
1151
- # like from your own database server or clients under your control, it could
1152
- # be dangerous to allow untrusted users to pass JSON sources into it.
1153
1368
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1154
1369
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1155
1370
  # The default options can be changed via method JSON.load_default_options=.
@@ -1160,17 +1375,17 @@ module JSON
1160
1375
  # <tt>parse(source, opts)</tt>; see #parse.
1161
1376
  #
1162
1377
  # Source for following examples:
1163
- # source = <<-EOT
1164
- # {
1165
- # "name": "Dave",
1166
- # "age" :40,
1167
- # "hats": [
1168
- # "Cattleman's",
1169
- # "Panama",
1170
- # "Tophat"
1171
- # ]
1172
- # }
1173
- # EOT
1378
+ # source = <<~JSON
1379
+ # {
1380
+ # "name": "Dave",
1381
+ # "age" :40,
1382
+ # "hats": [
1383
+ # "Cattleman's",
1384
+ # "Panama",
1385
+ # "Tophat"
1386
+ # ]
1387
+ # }
1388
+ # JSON
1174
1389
  #
1175
1390
  # Load a \String:
1176
1391
  # ruby = JSON.load(source)
@@ -1235,6 +1450,7 @@ module JSON
1235
1450
  # when Array
1236
1451
  # obj.map! {|v| deserialize_obj v }
1237
1452
  # end
1453
+ # obj
1238
1454
  # })
1239
1455
  # pp ruby
1240
1456
  # Output:
@@ -1256,24 +1472,14 @@ module JSON
1256
1472
  # #<Admin:0x00000000064c41f8
1257
1473
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1258
1474
  #
1259
- # source://json-2.6.2/lib/json/common.rb:557
1475
+ # pkg:gem/json#lib/json/common.rb:856
1260
1476
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1261
1477
 
1262
- # Sets or returns default options for the JSON.load method.
1263
- # Initially:
1264
- # opts = JSON.load_default_options
1265
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1266
- #
1267
- # source://json-2.6.2/lib/json/common.rb:420
1478
+ # pkg:gem/json#lib/json/common.rb:208
1268
1479
  def load_default_options; end
1269
1480
 
1270
- # Sets or returns default options for the JSON.load method.
1271
- # Initially:
1272
- # opts = JSON.load_default_options
1273
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1274
- #
1275
- # source://json-2.6.2/lib/json/common.rb:420
1276
- def load_default_options=(_arg0); end
1481
+ # pkg:gem/json#lib/json/common.rb:208
1482
+ def load_default_options=(val); end
1277
1483
 
1278
1484
  # :call-seq:
1279
1485
  # JSON.load_file(path, opts={}) -> object
@@ -1283,7 +1489,7 @@ module JSON
1283
1489
  #
1284
1490
  # See method #parse.
1285
1491
  #
1286
- # source://json-2.6.2/lib/json/common.rb:245
1492
+ # pkg:gem/json#lib/json/common.rb:390
1287
1493
  def load_file(filespec, opts = T.unsafe(nil)); end
1288
1494
 
1289
1495
  # :call-seq:
@@ -1294,7 +1500,7 @@ module JSON
1294
1500
  #
1295
1501
  # See method #parse!
1296
1502
  #
1297
- # source://json-2.6.2/lib/json/common.rb:256
1503
+ # pkg:gem/json#lib/json/common.rb:401
1298
1504
  def load_file!(filespec, opts = T.unsafe(nil)); end
1299
1505
 
1300
1506
  # :call-seq:
@@ -1325,17 +1531,17 @@ module JSON
1325
1531
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1326
1532
  #
1327
1533
  # Parses nested JSON objects:
1328
- # source = <<-EOT
1329
- # {
1330
- # "name": "Dave",
1331
- # "age" :40,
1332
- # "hats": [
1333
- # "Cattleman's",
1334
- # "Panama",
1335
- # "Tophat"
1336
- # ]
1337
- # }
1338
- # EOT
1534
+ # source = <<~JSON
1535
+ # {
1536
+ # "name": "Dave",
1537
+ # "age" :40,
1538
+ # "hats": [
1539
+ # "Cattleman's",
1540
+ # "Panama",
1541
+ # "Tophat"
1542
+ # ]
1543
+ # }
1544
+ # JSON
1339
1545
  # ruby = JSON.parse(source)
1340
1546
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1341
1547
  #
@@ -1345,7 +1551,7 @@ module JSON
1345
1551
  # # Raises JSON::ParserError (783: unexpected token at ''):
1346
1552
  # JSON.parse('')
1347
1553
  #
1348
- # source://json-2.6.2/lib/json/common.rb:215
1554
+ # pkg:gem/json#lib/json/common.rb:353
1349
1555
  def parse(source, opts = T.unsafe(nil)); end
1350
1556
 
1351
1557
  # :call-seq:
@@ -1360,19 +1566,17 @@ module JSON
1360
1566
  # which disables checking for nesting depth.
1361
1567
  # - Option +allow_nan+, if not provided, defaults to +true+.
1362
1568
  #
1363
- # source://json-2.6.2/lib/json/common.rb:230
1569
+ # pkg:gem/json#lib/json/common.rb:375
1364
1570
  def parse!(source, opts = T.unsafe(nil)); end
1365
1571
 
1366
- # Returns the JSON parser class that is used by JSON. This is either
1367
- # JSON::Ext::Parser or JSON::Pure::Parser:
1368
- # JSON.parser # => JSON::Ext::Parser
1572
+ # Returns the JSON parser class that is used by JSON.
1369
1573
  #
1370
- # source://json-2.6.2/lib/json/common.rb:29
1574
+ # pkg:gem/json#lib/json/common.rb:146
1371
1575
  def parser; end
1372
1576
 
1373
1577
  # Set the JSON parser class _parser_ to be used by JSON.
1374
1578
  #
1375
- # source://json-2.6.2/lib/json/common.rb:32
1579
+ # pkg:gem/json#lib/json/common.rb:149
1376
1580
  def parser=(parser); end
1377
1581
 
1378
1582
  # :call-seq:
@@ -1405,119 +1609,650 @@ module JSON
1405
1609
  # }
1406
1610
  # }
1407
1611
  #
1408
- # source://json-2.6.2/lib/json/common.rb:390
1612
+ # pkg:gem/json#lib/json/common.rb:509
1409
1613
  def pretty_generate(obj, opts = T.unsafe(nil)); end
1410
1614
 
1411
- # :stopdoc:
1412
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1413
- #
1414
- # source://json-2.6.2/lib/json/common.rb:390
1415
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
1615
+ # pkg:gem/json#lib/json/common.rb:987
1616
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1416
1617
 
1417
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1418
- #
1419
- # source://json-2.6.2/lib/json/common.rb:575
1420
- def recurse_proc(result, &proc); end
1618
+ # pkg:gem/json#lib/json/common.rb:997
1619
+ def restore(*_arg0, **_arg1, &_arg2); end
1421
1620
 
1422
- # source://json-2.6.2/lib/json/common.rb:557
1423
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1424
-
1425
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1426
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1427
- # JSON.state # => JSON::Ext::Generator::State
1621
+ # Sets or Returns the JSON generator state class that is used by JSON.
1428
1622
  #
1429
- # source://json-2.6.2/lib/json/common.rb:108
1623
+ # pkg:gem/json#lib/json/common.rb:182
1430
1624
  def state; end
1431
1625
 
1432
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1433
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1434
- # JSON.state # => JSON::Ext::Generator::State
1626
+ # Sets or Returns the JSON generator state class that is used by JSON.
1435
1627
  #
1436
- # source://json-2.6.2/lib/json/common.rb:108
1628
+ # pkg:gem/json#lib/json/common.rb:182
1437
1629
  def state=(_arg0); end
1438
1630
 
1439
1631
  # :stopdoc:
1440
- # I want to deprecate these later, so I'll first be silent about them, and
1441
- # later delete them.
1632
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1633
+ # so usage still exist in the wild.
1634
+ #
1635
+ # pkg:gem/json#lib/json/common.rb:967
1636
+ def unparse(*_arg0, **_arg1, &_arg2); end
1637
+
1638
+ # :call-seq:
1639
+ # JSON.unsafe_load(source, options = {}) -> object
1640
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
1641
+ #
1642
+ # Returns the Ruby objects created by parsing the given +source+.
1643
+ #
1644
+ # BEWARE: This method is meant to serialise data from trusted user input,
1645
+ # like from your own database server or clients under your control, it could
1646
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1442
1647
  #
1443
- # source://json-2.6.2/lib/json/common.rb:296
1444
- def unparse(obj, opts = T.unsafe(nil)); end
1648
+ # - Argument +source+ must be, or be convertible to, a \String:
1649
+ # - If +source+ responds to instance method +to_str+,
1650
+ # <tt>source.to_str</tt> becomes the source.
1651
+ # - If +source+ responds to instance method +to_io+,
1652
+ # <tt>source.to_io.read</tt> becomes the source.
1653
+ # - If +source+ responds to instance method +read+,
1654
+ # <tt>source.read</tt> becomes the source.
1655
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1656
+ # - Option +allow_blank+ specifies a truthy value.
1657
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1658
+ # - Otherwise, +source+ remains the source.
1659
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1660
+ # It will be called recursively with each result (depth-first order).
1661
+ # See details below.
1662
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1663
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1664
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1665
+ #
1666
+ # ---
1667
+ #
1668
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1669
+ # <tt>parse(source, opts)</tt>; see #parse.
1670
+ #
1671
+ # Source for following examples:
1672
+ # source = <<~JSON
1673
+ # {
1674
+ # "name": "Dave",
1675
+ # "age" :40,
1676
+ # "hats": [
1677
+ # "Cattleman's",
1678
+ # "Panama",
1679
+ # "Tophat"
1680
+ # ]
1681
+ # }
1682
+ # JSON
1683
+ #
1684
+ # Load a \String:
1685
+ # ruby = JSON.unsafe_load(source)
1686
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1687
+ #
1688
+ # Load an \IO object:
1689
+ # require 'stringio'
1690
+ # object = JSON.unsafe_load(StringIO.new(source))
1691
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1692
+ #
1693
+ # Load a \File object:
1694
+ # path = 't.json'
1695
+ # File.write(path, source)
1696
+ # File.open(path) do |file|
1697
+ # JSON.unsafe_load(file)
1698
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1699
+ #
1700
+ # ---
1701
+ #
1702
+ # When +proc+ is given:
1703
+ # - Modifies +source+ as above.
1704
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1705
+ # - Recursively calls <tt>proc(result)</tt>.
1706
+ # - Returns the final result.
1707
+ #
1708
+ # Example:
1709
+ # require 'json'
1710
+ #
1711
+ # # Some classes for the example.
1712
+ # class Base
1713
+ # def initialize(attributes)
1714
+ # @attributes = attributes
1715
+ # end
1716
+ # end
1717
+ # class User < Base; end
1718
+ # class Account < Base; end
1719
+ # class Admin < Base; end
1720
+ # # The JSON source.
1721
+ # json = <<-EOF
1722
+ # {
1723
+ # "users": [
1724
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1725
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1726
+ # ],
1727
+ # "accounts": [
1728
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1729
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1730
+ # ],
1731
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1732
+ # }
1733
+ # EOF
1734
+ # # Deserializer method.
1735
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1736
+ # type = obj.is_a?(Hash) && obj["type"]
1737
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1738
+ # end
1739
+ # # Call to JSON.unsafe_load
1740
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1741
+ # case obj
1742
+ # when Hash
1743
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1744
+ # when Array
1745
+ # obj.map! {|v| deserialize_obj v }
1746
+ # end
1747
+ # obj
1748
+ # })
1749
+ # pp ruby
1750
+ # Output:
1751
+ # {"users"=>
1752
+ # [#<User:0x00000000064c4c98
1753
+ # @attributes=
1754
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1755
+ # #<User:0x00000000064c4bd0
1756
+ # @attributes=
1757
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1758
+ # "accounts"=>
1759
+ # [{"account"=>
1760
+ # #<Account:0x00000000064c4928
1761
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1762
+ # {"account"=>
1763
+ # #<Account:0x00000000064c4680
1764
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1765
+ # "admins"=>
1766
+ # #<Admin:0x00000000064c41f8
1767
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1768
+ #
1769
+ # pkg:gem/json#lib/json/common.rb:685
1770
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1771
+
1772
+ # pkg:gem/json#lib/json/common.rb:208
1773
+ def unsafe_load_default_options; end
1774
+
1775
+ # pkg:gem/json#lib/json/common.rb:208
1776
+ def unsafe_load_default_options=(val); end
1777
+
1778
+ private
1779
+
1780
+ # pkg:gem/json#lib/json/common.rb:1010
1781
+ def const_missing(const_name); end
1782
+
1783
+ # pkg:gem/json#lib/json/common.rb:205
1784
+ def deprecated_singleton_attr_accessor(*attrs); end
1785
+
1786
+ # Called from the extension when a hash has both string and symbol keys
1787
+ #
1788
+ # pkg:gem/json#lib/json/common.rb:187
1789
+ def on_mixed_keys_hash(hash, do_raise); end
1445
1790
  end
1446
1791
  end
1447
1792
 
1448
- # source://json-2.6.2/lib/json/common.rb:114
1449
- JSON::CREATE_ID_TLS_KEY = T.let(T.unsafe(nil), String)
1793
+ # JSON::Coder holds a parser and generator configuration.
1794
+ #
1795
+ # module MyApp
1796
+ # JSONC_CODER = JSON::Coder.new(
1797
+ # allow_trailing_comma: true
1798
+ # )
1799
+ # end
1800
+ #
1801
+ # MyApp::JSONC_CODER.load(document)
1802
+ #
1803
+ # pkg:gem/json#lib/json/common.rb:1036
1804
+ class JSON::Coder
1805
+ # :call-seq:
1806
+ # JSON.new(options = nil, &block)
1807
+ #
1808
+ # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
1809
+ # See {Parsing Options}[rdoc-ref:JSON@Parsing+Options],
1810
+ # and {Generating Options}[rdoc-ref:JSON@Generating+Options].
1811
+ #
1812
+ # For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
1813
+ # encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
1814
+ # \JSON counterpart:
1815
+ #
1816
+ # module MyApp
1817
+ # API_JSON_CODER = JSON::Coder.new do |object|
1818
+ # case object
1819
+ # when Time
1820
+ # object.iso8601(3)
1821
+ # else
1822
+ # object # Unknown type, will raise
1823
+ # end
1824
+ # end
1825
+ # end
1826
+ #
1827
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
1828
+ #
1829
+ # pkg:gem/json#lib/json/common.rb:1061
1830
+ def initialize(options = T.unsafe(nil), &as_json); end
1831
+
1832
+ # call-seq:
1833
+ # dump(object) -> String
1834
+ # dump(object, io) -> io
1835
+ #
1836
+ # Serialize the given object into a \JSON document.
1837
+ #
1838
+ # pkg:gem/json#lib/json/common.rb:1079
1839
+ def dump(object, io = T.unsafe(nil)); end
1840
+
1841
+ # pkg:gem/json#lib/json/common.rb:1082
1842
+ def generate(object, io = T.unsafe(nil)); end
1843
+
1844
+ # call-seq:
1845
+ # load(string) -> Object
1846
+ #
1847
+ # Parse the given \JSON document and return an equivalent Ruby object.
1848
+ #
1849
+ # pkg:gem/json#lib/json/common.rb:1088
1850
+ def load(source); end
1851
+
1852
+ # call-seq:
1853
+ # load(path) -> Object
1854
+ #
1855
+ # Parse the given \JSON document and return an equivalent Ruby object.
1856
+ #
1857
+ # pkg:gem/json#lib/json/common.rb:1097
1858
+ def load_file(path); end
1859
+
1860
+ # pkg:gem/json#lib/json/common.rb:1091
1861
+ def parse(source); end
1862
+ end
1863
+
1864
+ # pkg:gem/json#lib/json/ext.rb:39
1865
+ class JSON::Ext::Generator::State
1866
+ # call-seq: new(opts = {})
1867
+ #
1868
+ # Instantiates a new State object, configured by _opts_.
1869
+ #
1870
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1871
+ # See {Generating Options}[rdoc-ref:JSON@Generating+Options].
1872
+ #
1873
+ # pkg:gem/json#lib/json/ext.rb:39
1874
+ def initialize(opts = T.unsafe(nil)); end
1875
+
1876
+ # call-seq: [](name)
1877
+ #
1878
+ # Returns the value returned by method +name+.
1879
+ #
1880
+ # pkg:gem/json#lib/json/ext/generator/state.rb:77
1881
+ def [](name); end
1882
+
1883
+ # call-seq: []=(name, value)
1884
+ #
1885
+ # Sets the attribute name to value.
1886
+ #
1887
+ # pkg:gem/json#lib/json/ext/generator/state.rb:91
1888
+ def []=(name, value); end
1889
+
1890
+ # pkg:gem/json#lib/json/ext.rb:39
1891
+ def _generate_no_fallback(*_arg0); end
1892
+
1893
+ # pkg:gem/json#lib/json/ext.rb:39
1894
+ def allow_nan=(_arg0); end
1895
+
1896
+ # pkg:gem/json#lib/json/ext.rb:39
1897
+ def allow_nan?; end
1898
+
1899
+ # pkg:gem/json#lib/json/ext.rb:39
1900
+ def array_nl; end
1450
1901
 
1451
- # source://json-2.6.2/lib/json/common.rb:111
1452
- JSON::DEFAULT_CREATE_ID = T.let(T.unsafe(nil), String)
1902
+ # pkg:gem/json#lib/json/ext.rb:39
1903
+ def array_nl=(_arg0); end
1453
1904
 
1454
- # source://json-2.6.2/lib/json/generic_object.rb:5
1905
+ # pkg:gem/json#lib/json/ext.rb:39
1906
+ def as_json; end
1907
+
1908
+ # pkg:gem/json#lib/json/ext.rb:39
1909
+ def as_json=(_arg0); end
1910
+
1911
+ # pkg:gem/json#lib/json/ext.rb:39
1912
+ def ascii_only=(_arg0); end
1913
+
1914
+ # pkg:gem/json#lib/json/ext.rb:39
1915
+ def ascii_only?; end
1916
+
1917
+ # pkg:gem/json#lib/json/ext.rb:39
1918
+ def buffer_initial_length; end
1919
+
1920
+ # pkg:gem/json#lib/json/ext.rb:39
1921
+ def buffer_initial_length=(_arg0); end
1922
+
1923
+ # pkg:gem/json#lib/json/ext.rb:39
1924
+ def check_circular?; end
1925
+
1926
+ # call-seq: configure(opts)
1927
+ #
1928
+ # Configure this State instance with the Hash _opts_, and return
1929
+ # itself.
1930
+ #
1931
+ # pkg:gem/json#lib/json/ext/generator/state.rb:23
1932
+ def configure(opts); end
1933
+
1934
+ # pkg:gem/json#lib/json/ext.rb:39
1935
+ def depth; end
1936
+
1937
+ # pkg:gem/json#lib/json/ext.rb:39
1938
+ def depth=(_arg0); end
1939
+
1940
+ # pkg:gem/json#lib/json/ext.rb:39
1941
+ def escape_slash; end
1942
+
1943
+ # pkg:gem/json#lib/json/ext.rb:39
1944
+ def escape_slash=(_arg0); end
1945
+
1946
+ # pkg:gem/json#lib/json/ext.rb:39
1947
+ def escape_slash?; end
1948
+
1949
+ # pkg:gem/json#lib/json/ext.rb:39
1950
+ def generate(*_arg0); end
1951
+
1952
+ # pkg:gem/json#lib/json/ext.rb:39
1953
+ def indent; end
1954
+
1955
+ # pkg:gem/json#lib/json/ext.rb:39
1956
+ def indent=(_arg0); end
1957
+
1958
+ # pkg:gem/json#lib/json/ext.rb:39
1959
+ def max_nesting; end
1960
+
1961
+ # pkg:gem/json#lib/json/ext.rb:39
1962
+ def max_nesting=(_arg0); end
1963
+
1964
+ # pkg:gem/json#lib/json/ext/generator/state.rb:36
1965
+ def merge(opts); end
1966
+
1967
+ # pkg:gem/json#lib/json/ext.rb:39
1968
+ def object_nl; end
1969
+
1970
+ # pkg:gem/json#lib/json/ext.rb:39
1971
+ def object_nl=(_arg0); end
1972
+
1973
+ # pkg:gem/json#lib/json/ext.rb:39
1974
+ def script_safe; end
1975
+
1976
+ # pkg:gem/json#lib/json/ext.rb:39
1977
+ def script_safe=(_arg0); end
1978
+
1979
+ # pkg:gem/json#lib/json/ext.rb:39
1980
+ def script_safe?; end
1981
+
1982
+ # pkg:gem/json#lib/json/ext.rb:39
1983
+ def space; end
1984
+
1985
+ # pkg:gem/json#lib/json/ext.rb:39
1986
+ def space=(_arg0); end
1987
+
1988
+ # pkg:gem/json#lib/json/ext.rb:39
1989
+ def space_before; end
1990
+
1991
+ # pkg:gem/json#lib/json/ext.rb:39
1992
+ def space_before=(_arg0); end
1993
+
1994
+ # pkg:gem/json#lib/json/ext.rb:39
1995
+ def strict; end
1996
+
1997
+ # pkg:gem/json#lib/json/ext.rb:39
1998
+ def strict=(_arg0); end
1999
+
2000
+ # pkg:gem/json#lib/json/ext.rb:39
2001
+ def strict?; end
2002
+
2003
+ # call-seq: to_h
2004
+ #
2005
+ # Returns the configuration instance variables as a hash, that can be
2006
+ # passed to the configure method.
2007
+ #
2008
+ # pkg:gem/json#lib/json/ext/generator/state.rb:42
2009
+ def to_h; end
2010
+
2011
+ # pkg:gem/json#lib/json/ext/generator/state.rb:72
2012
+ def to_hash; end
2013
+
2014
+ private
2015
+
2016
+ # pkg:gem/json#lib/json/ext.rb:39
2017
+ def _configure(_arg0); end
2018
+
2019
+ # pkg:gem/json#lib/json/ext.rb:39
2020
+ def allow_duplicate_key?; end
2021
+
2022
+ # pkg:gem/json#lib/json/ext.rb:39
2023
+ def initialize_copy(_arg0); end
2024
+
2025
+ class << self
2026
+ # pkg:gem/json#lib/json/ext.rb:39
2027
+ def _generate_no_fallback(_arg0, _arg1, _arg2); end
2028
+
2029
+ # pkg:gem/json#lib/json/ext.rb:39
2030
+ def from_state(_arg0); end
2031
+
2032
+ # pkg:gem/json#lib/json/ext.rb:39
2033
+ def generate(_arg0, _arg1, _arg2); end
2034
+ end
2035
+ end
2036
+
2037
+ # pkg:gem/json#lib/json/ext.rb:9
2038
+ class JSON::Ext::Parser
2039
+ # pkg:gem/json#lib/json/ext.rb:17
2040
+ def initialize(source, opts = T.unsafe(nil)); end
2041
+
2042
+ # pkg:gem/json#lib/json/ext.rb:26
2043
+ def parse; end
2044
+
2045
+ # pkg:gem/json#lib/json/ext.rb:22
2046
+ def source; end
2047
+
2048
+ class << self
2049
+ # pkg:gem/json#lib/json/ext.rb:11
2050
+ def parse(_arg0, _arg1); end
2051
+ end
2052
+ end
2053
+
2054
+ # pkg:gem/json#lib/json/ext.rb:32
2055
+ JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
2056
+
2057
+ # pkg:gem/json#lib/json/ext.rb:31
2058
+ class JSON::Ext::ParserConfig
2059
+ # pkg:gem/json#lib/json/ext.rb:31
2060
+ def initialize(_arg0); end
2061
+
2062
+ # pkg:gem/json#lib/json/ext.rb:31
2063
+ def parse(_arg0); end
2064
+ end
2065
+
2066
+ # Fragment of JSON document that is to be included as is:
2067
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
2068
+ # JSON.generate({ count: 3, items: fragments })
2069
+ #
2070
+ # This allows to easily assemble multiple JSON fragments that have
2071
+ # been persisted somewhere without having to parse them nor resorting
2072
+ # to string interpolation.
2073
+ #
2074
+ # Note: no validation is performed on the provided string. It is the
2075
+ # responsibility of the caller to ensure the string contains valid JSON.
2076
+ #
2077
+ # pkg:gem/json#lib/json/common.rb:289
2078
+ class JSON::Fragment < ::Struct
2079
+ # pkg:gem/json#lib/json/common.rb:290
2080
+ def initialize(json); end
2081
+
2082
+ # pkg:gem/json#lib/json/common.rb:289
2083
+ def json; end
2084
+
2085
+ # pkg:gem/json#lib/json/common.rb:289
2086
+ def json=(_); end
2087
+
2088
+ # pkg:gem/json#lib/json/common.rb:298
2089
+ def to_json(state = T.unsafe(nil), *_arg1); end
2090
+
2091
+ class << self
2092
+ # pkg:gem/json#lib/json/common.rb:289
2093
+ def [](*_arg0); end
2094
+
2095
+ # pkg:gem/json#lib/json/common.rb:289
2096
+ def inspect; end
2097
+
2098
+ # pkg:gem/json#lib/json/common.rb:289
2099
+ def keyword_init?; end
2100
+
2101
+ # pkg:gem/json#lib/json/common.rb:289
2102
+ def members; end
2103
+
2104
+ # pkg:gem/json#lib/json/common.rb:289
2105
+ def new(*_arg0); end
2106
+ end
2107
+ end
2108
+
2109
+ # This exception is raised if a generator or unparser error occurs.
2110
+ #
2111
+ # pkg:gem/json#lib/json/common.rb:259
2112
+ class JSON::GeneratorError < ::JSON::JSONError
2113
+ # pkg:gem/json#lib/json/common.rb:262
2114
+ def initialize(message, invalid_object = T.unsafe(nil)); end
2115
+
2116
+ # pkg:gem/json#lib/json/common.rb:267
2117
+ def detailed_message(*_arg0, **_arg1, &_arg2); end
2118
+
2119
+ # pkg:gem/json#lib/json/common.rb:260
2120
+ def invalid_object; end
2121
+ end
2122
+
2123
+ # pkg:gem/json#lib/json/common.rb:1102
2124
+ module JSON::GeneratorMethods
2125
+ # call-seq: to_json(*)
2126
+ #
2127
+ # Converts this object into a JSON string.
2128
+ # If this object doesn't directly maps to a JSON native type,
2129
+ # first convert it to a string (calling #to_s), then converts
2130
+ # it to a JSON string, and returns the result.
2131
+ # This is a fallback, if no special method #to_json was defined for some object.
2132
+ #
2133
+ # pkg:gem/json#lib/json/common.rb:1110
2134
+ def to_json(state = T.unsafe(nil), *_arg1); end
2135
+ end
2136
+
2137
+ # pkg:gem/json#lib/json/generic_object.rb:9
1455
2138
  class JSON::GenericObject < ::OpenStruct
1456
- # source://json-2.6.2/lib/json/generic_object.rb:63
2139
+ # pkg:gem/json#lib/json/generic_object.rb:59
1457
2140
  def as_json(*_arg0); end
1458
2141
 
1459
- # source://json-2.6.2/lib/json/generic_object.rb:47
2142
+ # pkg:gem/json#lib/json/generic_object.rb:51
1460
2143
  def to_hash; end
1461
2144
 
1462
- # source://json-2.6.2/lib/json/generic_object.rb:67
2145
+ # pkg:gem/json#lib/json/generic_object.rb:63
1463
2146
  def to_json(*a); end
1464
2147
 
1465
- # source://json-2.6.2/lib/json/generic_object.rb:59
2148
+ # pkg:gem/json#lib/json/generic_object.rb:55
1466
2149
  def |(other); end
1467
2150
 
1468
2151
  class << self
1469
- # source://json-2.6.2/lib/json/generic_object.rb:41
2152
+ # pkg:gem/json#lib/json/generic_object.rb:11
2153
+ def [](*_arg0); end
2154
+
2155
+ # pkg:gem/json#lib/json/generic_object.rb:45
1470
2156
  def dump(obj, *args); end
1471
2157
 
1472
- # source://json-2.6.2/lib/json/generic_object.rb:21
2158
+ # pkg:gem/json#lib/json/generic_object.rb:25
1473
2159
  def from_hash(object); end
1474
2160
 
1475
- # Sets the attribute json_creatable
1476
- #
1477
- # @param value the value to set the attribute json_creatable to.
1478
- #
1479
- # source://json-2.6.2/lib/json/generic_object.rb:13
2161
+ # pkg:gem/json#lib/json/generic_object.rb:17
1480
2162
  def json_creatable=(_arg0); end
1481
2163
 
1482
- # @return [Boolean]
1483
- #
1484
- # source://json-2.6.2/lib/json/generic_object.rb:9
2164
+ # pkg:gem/json#lib/json/generic_object.rb:13
1485
2165
  def json_creatable?; end
1486
2166
 
1487
- # source://json-2.6.2/lib/json/generic_object.rb:15
2167
+ # pkg:gem/json#lib/json/generic_object.rb:19
1488
2168
  def json_create(data); end
1489
2169
 
1490
- # source://json-2.6.2/lib/json/generic_object.rb:36
2170
+ # pkg:gem/json#lib/json/generic_object.rb:40
1491
2171
  def load(source, proc = T.unsafe(nil), opts = T.unsafe(nil)); end
1492
2172
  end
1493
2173
  end
1494
2174
 
1495
- # The base exception for JSON errors.
2175
+ # pkg:gem/json#lib/json/common.rb:358
2176
+ JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
2177
+
2178
+ # pkg:gem/json#lib/json/common.rb:471
2179
+ JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
2180
+
2181
+ # pkg:gem/json#lib/json/common.rb:152
2182
+ JSON::Parser = JSON::Ext::Parser
2183
+
2184
+ # This exception is raised if a parser error occurs.
1496
2185
  #
1497
- # source://json-2.6.2/lib/json/common.rb:137
1498
- class JSON::JSONError < ::StandardError
2186
+ # pkg:gem/json#lib/json/common.rb:250
2187
+ class JSON::ParserError < ::JSON::JSONError
2188
+ # pkg:gem/json#lib/json/common.rb:251
2189
+ def column; end
2190
+
2191
+ # pkg:gem/json#lib/json/common.rb:251
2192
+ def line; end
2193
+ end
2194
+
2195
+ # pkg:gem/json#lib/json/common.rb:8
2196
+ module JSON::ParserOptions
1499
2197
  class << self
1500
- # source://json-2.6.2/lib/json/common.rb:138
1501
- def wrap(exception); end
2198
+ # pkg:gem/json#lib/json/common.rb:10
2199
+ def prepare(opts); end
2200
+
2201
+ private
2202
+
2203
+ # pkg:gem/json#lib/json/common.rb:40
2204
+ def array_class_proc(array_class, on_load); end
2205
+
2206
+ # TODO: extract :create_additions support to another gem for version 3.0
2207
+ #
2208
+ # pkg:gem/json#lib/json/common.rb:52
2209
+ def create_additions_proc(opts); end
2210
+
2211
+ # pkg:gem/json#lib/json/common.rb:95
2212
+ def create_additions_warning; end
2213
+
2214
+ # pkg:gem/json#lib/json/common.rb:29
2215
+ def object_class_proc(object_class, on_load); end
1502
2216
  end
1503
2217
  end
1504
2218
 
1505
- # source://json-2.6.2/lib/json/common.rb:35
1506
- JSON::Parser = JSON::Ext::Parser
2219
+ # pkg:gem/json#lib/json/ext.rb:31
2220
+ class JSON::ResumableParser
2221
+ # pkg:gem/json#lib/json/ext.rb:31
2222
+ def initialize(*_arg0); end
1507
2223
 
1508
- # source://json-2.6.2/lib/json/common.rb:73
1509
- JSON::State = JSON::Ext::Generator::State
2224
+ # pkg:gem/json#lib/json/ext.rb:31
2225
+ def <<(_arg0); end
1510
2226
 
1511
- # For backwards compatibility
1512
- #
1513
- # source://json-2.6.2/lib/json/common.rb:159
1514
- JSON::UnparserError = JSON::GeneratorError
2227
+ # pkg:gem/json#lib/json/ext.rb:31
2228
+ def clear; end
1515
2229
 
1516
- # Adds a `byebug` method to the Kernel module.
1517
- #
1518
- # Dropping a `byebug` call anywhere in your code, you get a debug prompt.
1519
- #
1520
- # source://json-2.6.2/lib/json/common.rb:658
2230
+ # pkg:gem/json#lib/json/ext.rb:31
2231
+ def eos?; end
2232
+
2233
+ # pkg:gem/json#lib/json/ext.rb:31
2234
+ def parse; end
2235
+
2236
+ # pkg:gem/json#lib/json/ext.rb:31
2237
+ def parsed_bytes; end
2238
+
2239
+ # pkg:gem/json#lib/json/ext.rb:31
2240
+ def partial_value; end
2241
+
2242
+ # pkg:gem/json#lib/json/ext.rb:31
2243
+ def rest; end
2244
+
2245
+ # pkg:gem/json#lib/json/ext.rb:31
2246
+ def value; end
2247
+
2248
+ # pkg:gem/json#lib/json/ext.rb:31
2249
+ def value?; end
2250
+ end
2251
+
2252
+ # pkg:gem/json#lib/json/common.rb:173
2253
+ JSON::State = JSON::Ext::Generator::State
2254
+
2255
+ # pkg:gem/json#lib/json/common.rb:1127
1521
2256
  module Kernel
1522
2257
  private
1523
2258
 
@@ -1528,18 +2263,25 @@ module Kernel
1528
2263
  # The _opts_ argument is passed through to generate/parse respectively. See
1529
2264
  # generate and parse for their documentation.
1530
2265
  #
1531
- # source://json-2.6.2/lib/json/common.rb:685
1532
- def JSON(object, *args); end
2266
+ # pkg:gem/json#lib/json/common.rb:1166
2267
+ def JSON(object, opts = T.unsafe(nil)); end
1533
2268
 
1534
2269
  # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1535
2270
  # one line.
1536
2271
  #
1537
- # source://json-2.6.2/lib/json/common.rb:663
2272
+ # pkg:gem/json#lib/json/common.rb:1132
1538
2273
  def j(*objs); end
1539
2274
 
1540
2275
  # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1541
2276
  # indentation and over many lines.
1542
2277
  #
1543
- # source://json-2.6.2/lib/json/common.rb:672
2278
+ # pkg:gem/json#lib/json/common.rb:1147
1544
2279
  def jj(*objs); end
1545
2280
  end
2281
+
2282
+ # pkg:gem/json#lib/json/common.rb:1171
2283
+ class Object < ::BasicObject
2284
+ include ::Kernel
2285
+ include ::PP::ObjectMixin
2286
+ include ::JSON::GeneratorMethods
2287
+ end