tsumanne 0.0.2 → 0.0.4
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.
- checksums.yaml +4 -4
- data/.dockerignore +8 -0
- data/.mdlrc +6 -0
- data/.rubocop.yml +20 -12
- data/Dockerfile +24 -0
- data/README.md +0 -4
- data/Rakefile +19 -16
- data/exe/tsumanne +2 -1
- data/lib/tsumanne/api.rb +22 -21
- data/lib/tsumanne/cli.rb +153 -2
- data/lib/tsumanne/models/get_threads.rb +8 -3
- data/lib/tsumanne/models/register_thread.rb +5 -1
- data/lib/tsumanne/models/search_indexes.rb +7 -2
- data/lib/tsumanne/models/search_thread_from_uri.rb +14 -2
- data/lib/tsumanne/version.rb +1 -1
- data/mise.toml +42 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +45 -79
- data/sorbet/rbi/gems/benchmark@0.5.0.rbi +621 -0
- data/sorbet/rbi/gems/{chef-utils@18.2.7.rbi → chef-utils@18.8.54.rbi} +1 -0
- data/sorbet/rbi/gems/{concurrent-ruby@1.2.2.rbi → concurrent-ruby@1.3.5.rbi} +1 -0
- data/sorbet/rbi/gems/{diff-lcs@1.5.0.rbi → diff-lcs@1.6.2.rbi} +183 -199
- data/sorbet/rbi/gems/docile@1.4.0.rbi +147 -147
- data/sorbet/rbi/gems/{erubi@1.12.0.rbi → erubi@1.13.1.rbi} +36 -26
- data/sorbet/rbi/gems/{json@2.6.3.rbi → json@2.19.4.rbi} +920 -251
- data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +32 -63
- data/sorbet/rbi/gems/{kramdown@2.4.0.rbi → kramdown@2.5.1.rbi} +896 -711
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
- data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
- data/sorbet/rbi/gems/{mdl@0.12.0.rbi → mdl@0.15.0.rbi} +109 -113
- data/sorbet/rbi/gems/mixlib-cli@2.1.8.rbi +35 -41
- data/sorbet/rbi/gems/mixlib-config@3.0.27.rbi +147 -142
- data/sorbet/rbi/gems/{mixlib-shellout@3.2.7.rbi → mixlib-shellout@3.3.9.rbi} +127 -150
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +45 -56
- data/sorbet/rbi/gems/optimist@3.2.1.rbi +895 -0
- data/sorbet/rbi/gems/parallel@1.28.0.rbi +270 -0
- data/sorbet/rbi/gems/parser@3.3.11.1.rbi +5229 -0
- data/sorbet/rbi/gems/prism@1.9.0.rbi +42224 -0
- data/sorbet/rbi/gems/{racc@1.7.1.rbi → racc@1.8.1.rbi} +48 -44
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +101 -141
- data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.4.2.rbi} +867 -761
- data/sorbet/rbi/gems/rbi@0.3.10.rbi +5520 -0
- data/sorbet/rbi/gems/rbs@4.0.2.rbi +6908 -0
- data/sorbet/rbi/gems/regexp_parser@2.12.0.rbi +3398 -0
- data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
- data/sorbet/rbi/gems/{rexml@3.2.6.rbi → rexml@3.4.4.rbi} +1032 -908
- data/sorbet/rbi/gems/{rspec-core@3.12.2.rbi → rspec-core@3.13.6.rbi} +2860 -4206
- data/sorbet/rbi/gems/rspec-expectations@3.13.5.rbi +6108 -0
- data/sorbet/rbi/gems/{rspec-mocks@3.12.6.rbi → rspec-mocks@3.13.7.rbi} +1264 -1787
- data/sorbet/rbi/gems/rspec-support@3.13.6.rbi +1274 -0
- data/sorbet/rbi/gems/rspec@3.13.2.rbi +15 -0
- data/sorbet/rbi/gems/rubocop-ast@1.49.1.rbi +7212 -0
- data/sorbet/rbi/gems/rubocop-performance@1.26.1.rbi +3403 -0
- data/sorbet/rbi/gems/{rubocop-rake@0.6.0.rbi → rubocop-rake@0.7.1.rbi} +89 -103
- data/sorbet/rbi/gems/rubocop-rspec@3.9.0.rbi +7606 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.12.0.rbi +2448 -0
- data/sorbet/rbi/gems/rubocop@1.86.1.rbi +62232 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +326 -655
- data/sorbet/rbi/gems/rubydex@0.1.0.beta14.rbi +655 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +24 -158
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +450 -606
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +32 -166
- data/sorbet/rbi/gems/spoom@1.7.13.rbi +6151 -0
- data/sorbet/rbi/gems/{tapioca@0.11.8.rbi → tapioca@0.19.1.rbi} +1609 -1379
- data/sorbet/rbi/gems/{thor@1.2.2.rbi → thor@1.5.0.rbi} +1075 -1170
- data/sorbet/rbi/gems/tomlrb@2.0.3.rbi +1 -0
- data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
- data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
- data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
- metadata +69 -66
- data/.ruby-version +0 -1
- data/sorbet/rbi/gems/base64@0.1.1.rbi +0 -172
- data/sorbet/rbi/gems/ffi-compiler@1.0.1.rbi +0 -206
- data/sorbet/rbi/gems/ffi@1.15.5.rbi +0 -1994
- data/sorbet/rbi/gems/http-parser@1.2.3.rbi +0 -422
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +0 -14237
- data/sorbet/rbi/gems/mhtml@0.1.6.rbi +0 -353
- data/sorbet/rbi/gems/parallel@1.23.0.rbi +0 -273
- data/sorbet/rbi/gems/parser@3.2.2.3.rbi +0 -7253
- data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +0 -951
- data/sorbet/rbi/gems/rbi@0.0.17.rbi +0 -2967
- data/sorbet/rbi/gems/regexp_parser@2.8.1.rbi +0 -3749
- data/sorbet/rbi/gems/rspec-expectations@3.12.3.rbi +0 -8100
- data/sorbet/rbi/gems/rspec-support@3.12.1.rbi +0 -1609
- data/sorbet/rbi/gems/rspec@3.12.0.rbi +0 -82
- data/sorbet/rbi/gems/rubocop-ast@1.29.0.rbi +0 -7144
- data/sorbet/rbi/gems/rubocop-capybara@2.18.0.rbi +0 -827
- data/sorbet/rbi/gems/rubocop-factory_bot@2.23.1.rbi +0 -812
- data/sorbet/rbi/gems/rubocop-performance@1.19.0.rbi +0 -3157
- data/sorbet/rbi/gems/rubocop-rspec@2.23.2.rbi +0 -7691
- data/sorbet/rbi/gems/rubocop-sorbet@0.7.3.rbi +0 -1226
- data/sorbet/rbi/gems/rubocop@1.56.2.rbi +0 -56541
- data/sorbet/rbi/gems/spoom@1.2.3.rbi +0 -3199
- data/sorbet/rbi/gems/syntax_tree@6.1.1.rbi +0 -22855
- data/sorbet/rbi/gems/unicode-display_width@2.4.2.rbi +0 -65
- data/sorbet/rbi/gems/unparser@0.6.8.rbi +0 -4525
- data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +0 -425
- data/sorbet/rbi/gems/yard@0.9.34.rbi +0 -18219
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
# typed:
|
|
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
|
-
class Class < ::Module
|
|
9
|
-
# Returns true if this class can be used to create an instance
|
|
10
|
-
# from a serialised JSON string. The class has to implement a class
|
|
11
|
-
# method _json_create_ that expects a hash as first parameter. The hash
|
|
12
|
-
# should include the required data.
|
|
13
|
-
#
|
|
14
|
-
# @return [Boolean]
|
|
15
|
-
#
|
|
16
|
-
# source://json//json/common.rb#700
|
|
17
|
-
def json_creatable?; end
|
|
18
|
-
end
|
|
19
7
|
|
|
20
8
|
# = JavaScript \Object Notation (\JSON)
|
|
21
9
|
#
|
|
22
10
|
# \JSON is a lightweight data-interchange format.
|
|
23
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
|
+
#
|
|
24
21
|
# A \JSON value is one of the following:
|
|
25
22
|
# - Double-quoted text: <tt>"foo"</tt>.
|
|
26
23
|
# - Number: +1+, +1.0+, +2.0e2+.
|
|
@@ -142,6 +139,24 @@ end
|
|
|
142
139
|
#
|
|
143
140
|
# ---
|
|
144
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
|
+
#
|
|
145
160
|
# Option +allow_nan+ (boolean) specifies whether to allow
|
|
146
161
|
# NaN, Infinity, and MinusInfinity in +source+;
|
|
147
162
|
# defaults to +false+.
|
|
@@ -158,8 +173,47 @@ end
|
|
|
158
173
|
# ruby = JSON.parse(source, {allow_nan: true})
|
|
159
174
|
# ruby # => [NaN, Infinity, -Infinity]
|
|
160
175
|
#
|
|
176
|
+
# ---
|
|
177
|
+
#
|
|
178
|
+
# Option +allow_trailing_comma+ (boolean) specifies whether to allow
|
|
179
|
+
# trailing commas in objects and arrays;
|
|
180
|
+
# defaults to +false+.
|
|
181
|
+
#
|
|
182
|
+
# With the default, +false+:
|
|
183
|
+
# JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
|
|
184
|
+
#
|
|
185
|
+
# When enabled:
|
|
186
|
+
# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
|
|
187
|
+
#
|
|
188
|
+
# ---
|
|
189
|
+
#
|
|
190
|
+
# Option +allow_control_characters+ (boolean) specifies whether to allow
|
|
191
|
+
# unescaped ASCII control characters, such as newlines, in strings;
|
|
192
|
+
# defaults to +false+.
|
|
193
|
+
#
|
|
194
|
+
# With the default, +false+:
|
|
195
|
+
# JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
|
|
196
|
+
#
|
|
197
|
+
# When enabled:
|
|
198
|
+
# JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
|
|
199
|
+
#
|
|
200
|
+
# ---
|
|
201
|
+
#
|
|
202
|
+
# Option +allow_invalid_escape+ (boolean) specifies whether to ignore backslahes that are followed
|
|
203
|
+
# by an invalid escape character in strings;
|
|
204
|
+
# defaults to +false+.
|
|
205
|
+
#
|
|
206
|
+
# With the default, +false+:
|
|
207
|
+
# JSON.parse('"Hell\o"') # invalid escape character in string (JSON::ParserError)
|
|
208
|
+
#
|
|
209
|
+
# When enabled:
|
|
210
|
+
# JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello"
|
|
211
|
+
#
|
|
161
212
|
# ====== Output Options
|
|
162
213
|
#
|
|
214
|
+
# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
|
|
215
|
+
# defaults to +false+.
|
|
216
|
+
#
|
|
163
217
|
# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
|
|
164
218
|
# should be Symbols;
|
|
165
219
|
# defaults to +false+ (use Strings).
|
|
@@ -284,8 +338,27 @@ end
|
|
|
284
338
|
# JSON.generate(JSON::MinusInfinity)
|
|
285
339
|
#
|
|
286
340
|
# Allow:
|
|
287
|
-
# ruby = [Float::
|
|
288
|
-
# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
|
|
341
|
+
# ruby = [Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity]
|
|
342
|
+
# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,NaN,Infinity,-Infinity]'
|
|
343
|
+
#
|
|
344
|
+
# ---
|
|
345
|
+
#
|
|
346
|
+
# Option +allow_duplicate_key+ (boolean) specifies whether
|
|
347
|
+
# hashes with duplicate keys should be allowed or produce an error.
|
|
348
|
+
# defaults to emit a deprecation warning.
|
|
349
|
+
#
|
|
350
|
+
# With the default, (not set):
|
|
351
|
+
# Warning[:deprecated] = true
|
|
352
|
+
# JSON.generate({ foo: 1, "foo" => 2 })
|
|
353
|
+
# # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
|
|
354
|
+
# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
|
|
355
|
+
# # => '{"foo":1,"foo":2}'
|
|
356
|
+
#
|
|
357
|
+
# With <tt>false</tt>
|
|
358
|
+
# JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
|
|
359
|
+
# # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
|
|
360
|
+
#
|
|
361
|
+
# In version 3.0, <tt>false</tt> will become the default.
|
|
289
362
|
#
|
|
290
363
|
# ---
|
|
291
364
|
#
|
|
@@ -300,6 +373,15 @@ end
|
|
|
300
373
|
# # Raises JSON::NestingError (nesting of 2 is too deep):
|
|
301
374
|
# JSON.generate(obj, max_nesting: 2)
|
|
302
375
|
#
|
|
376
|
+
# ====== Escaping Options
|
|
377
|
+
#
|
|
378
|
+
# Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
|
|
379
|
+
# and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
|
|
380
|
+
# tags.
|
|
381
|
+
#
|
|
382
|
+
# Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
|
|
383
|
+
# should be escaped.
|
|
384
|
+
#
|
|
303
385
|
# ====== Output Options
|
|
304
386
|
#
|
|
305
387
|
# The default formatting options generate the most compact
|
|
@@ -357,6 +439,9 @@ end
|
|
|
357
439
|
#
|
|
358
440
|
# == \JSON Additions
|
|
359
441
|
#
|
|
442
|
+
# Note that JSON Additions must only be used with trusted data, and is
|
|
443
|
+
# deprecated.
|
|
444
|
+
#
|
|
360
445
|
# When you "round trip" a non-\String object from Ruby to \JSON and back,
|
|
361
446
|
# you have a new \String, instead of the object you began with:
|
|
362
447
|
# ruby0 = Range.new(0, 2)
|
|
@@ -384,13 +469,13 @@ end
|
|
|
384
469
|
# json1 = JSON.generate(ruby)
|
|
385
470
|
# ruby1 = JSON.parse(json1, create_additions: true)
|
|
386
471
|
# # Make a nice display.
|
|
387
|
-
# display =
|
|
388
|
-
#
|
|
389
|
-
#
|
|
390
|
-
#
|
|
391
|
-
#
|
|
392
|
-
#
|
|
393
|
-
#
|
|
472
|
+
# display = <<~EOT
|
|
473
|
+
# Generated JSON:
|
|
474
|
+
# Without addition: #{json0} (#{json0.class})
|
|
475
|
+
# With addition: #{json1} (#{json1.class})
|
|
476
|
+
# Parsed JSON:
|
|
477
|
+
# Without addition: #{ruby0.inspect} (#{ruby0.class})
|
|
478
|
+
# With addition: #{ruby1.inspect} (#{ruby1.class})
|
|
394
479
|
# EOT
|
|
395
480
|
# puts display
|
|
396
481
|
#
|
|
@@ -568,13 +653,13 @@ end
|
|
|
568
653
|
# json1 = JSON.generate(foo1)
|
|
569
654
|
# obj1 = JSON.parse(json1, create_additions: true)
|
|
570
655
|
# # Make a nice display.
|
|
571
|
-
# display =
|
|
572
|
-
#
|
|
573
|
-
#
|
|
574
|
-
#
|
|
575
|
-
#
|
|
576
|
-
#
|
|
577
|
-
#
|
|
656
|
+
# display = <<~EOT
|
|
657
|
+
# Generated JSON:
|
|
658
|
+
# Without custom addition: #{json0} (#{json0.class})
|
|
659
|
+
# With custom addition: #{json1} (#{json1.class})
|
|
660
|
+
# Parsed JSON:
|
|
661
|
+
# Without custom addition: #{obj0.inspect} (#{obj0.class})
|
|
662
|
+
# With custom addition: #{obj1.inspect} (#{obj1.class})
|
|
578
663
|
# EOT
|
|
579
664
|
# puts display
|
|
580
665
|
#
|
|
@@ -586,6 +671,8 @@ end
|
|
|
586
671
|
# Parsed JSON:
|
|
587
672
|
# Without custom addition: "#<Foo:0x0000000006534e80>" (String)
|
|
588
673
|
# With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
|
|
674
|
+
#
|
|
675
|
+
# pkg:gem/json#lib/json/version.rb:3
|
|
589
676
|
module JSON
|
|
590
677
|
private
|
|
591
678
|
|
|
@@ -617,8 +704,8 @@ module JSON
|
|
|
617
704
|
# Output:
|
|
618
705
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
|
619
706
|
#
|
|
620
|
-
#
|
|
621
|
-
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
|
|
707
|
+
# pkg:gem/json#lib/json/common.rb:932
|
|
708
|
+
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
|
622
709
|
|
|
623
710
|
# :call-seq:
|
|
624
711
|
# JSON.fast_generate(obj, opts) -> new_string
|
|
@@ -634,21 +721,18 @@ module JSON
|
|
|
634
721
|
# # Raises SystemStackError (stack level too deep):
|
|
635
722
|
# JSON.fast_generate(a)
|
|
636
723
|
#
|
|
637
|
-
#
|
|
724
|
+
# pkg:gem/json#lib/json/common.rb:462
|
|
638
725
|
def fast_generate(obj, opts = T.unsafe(nil)); end
|
|
639
726
|
|
|
640
|
-
# :
|
|
641
|
-
|
|
642
|
-
#
|
|
643
|
-
# source://json//json/common.rb#335
|
|
644
|
-
def fast_unparse(obj, opts = T.unsafe(nil)); end
|
|
727
|
+
# pkg:gem/json#lib/json/common.rb:977
|
|
728
|
+
def fast_unparse(*_arg0, **_arg1, &_arg2); end
|
|
645
729
|
|
|
646
730
|
# :call-seq:
|
|
647
731
|
# JSON.generate(obj, opts = nil) -> new_string
|
|
648
732
|
#
|
|
649
733
|
# Returns a \String containing the generated \JSON data.
|
|
650
734
|
#
|
|
651
|
-
# See also JSON.
|
|
735
|
+
# See also JSON.pretty_generate.
|
|
652
736
|
#
|
|
653
737
|
# Argument +obj+ is the Ruby object to be converted to \JSON.
|
|
654
738
|
#
|
|
@@ -679,14 +763,25 @@ module JSON
|
|
|
679
763
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
|
680
764
|
# JSON.generate(a)
|
|
681
765
|
#
|
|
682
|
-
#
|
|
766
|
+
# pkg:gem/json#lib/json/common.rb:441
|
|
683
767
|
def generate(obj, opts = T.unsafe(nil)); end
|
|
684
768
|
|
|
685
769
|
# :call-seq:
|
|
770
|
+
# JSON.load(source, options = {}) -> object
|
|
686
771
|
# JSON.load(source, proc = nil, options = {}) -> object
|
|
687
772
|
#
|
|
688
773
|
# Returns the Ruby objects created by parsing the given +source+.
|
|
689
774
|
#
|
|
775
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
776
|
+
# like from your own database server or clients under your control, it could
|
|
777
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
778
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
|
779
|
+
#
|
|
780
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
|
781
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
|
782
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
|
783
|
+
# by default.
|
|
784
|
+
#
|
|
690
785
|
# - Argument +source+ must be, or be convertible to, a \String:
|
|
691
786
|
# - If +source+ responds to instance method +to_str+,
|
|
692
787
|
# <tt>source.to_str</tt> becomes the source.
|
|
@@ -701,9 +796,6 @@ module JSON
|
|
|
701
796
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
|
702
797
|
# It will be called recursively with each result (depth-first order).
|
|
703
798
|
# See details below.
|
|
704
|
-
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
705
|
-
# like from your own database server or clients under your control, it could
|
|
706
|
-
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
707
799
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
|
708
800
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
|
709
801
|
# The default options can be changed via method JSON.load_default_options=.
|
|
@@ -714,17 +806,17 @@ module JSON
|
|
|
714
806
|
# <tt>parse(source, opts)</tt>; see #parse.
|
|
715
807
|
#
|
|
716
808
|
# Source for following examples:
|
|
717
|
-
# source =
|
|
718
|
-
#
|
|
719
|
-
#
|
|
720
|
-
#
|
|
721
|
-
#
|
|
722
|
-
#
|
|
723
|
-
#
|
|
724
|
-
#
|
|
725
|
-
#
|
|
726
|
-
#
|
|
727
|
-
#
|
|
809
|
+
# source = <<~JSON
|
|
810
|
+
# {
|
|
811
|
+
# "name": "Dave",
|
|
812
|
+
# "age" :40,
|
|
813
|
+
# "hats": [
|
|
814
|
+
# "Cattleman's",
|
|
815
|
+
# "Panama",
|
|
816
|
+
# "Tophat"
|
|
817
|
+
# ]
|
|
818
|
+
# }
|
|
819
|
+
# JSON
|
|
728
820
|
#
|
|
729
821
|
# Load a \String:
|
|
730
822
|
# ruby = JSON.load(source)
|
|
@@ -789,6 +881,7 @@ module JSON
|
|
|
789
881
|
# when Array
|
|
790
882
|
# obj.map! {|v| deserialize_obj v }
|
|
791
883
|
# end
|
|
884
|
+
# obj
|
|
792
885
|
# })
|
|
793
886
|
# pp ruby
|
|
794
887
|
# Output:
|
|
@@ -810,7 +903,7 @@ module JSON
|
|
|
810
903
|
# #<Admin:0x00000000064c41f8
|
|
811
904
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
|
812
905
|
#
|
|
813
|
-
#
|
|
906
|
+
# pkg:gem/json#lib/json/common.rb:856
|
|
814
907
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
|
815
908
|
|
|
816
909
|
# :call-seq:
|
|
@@ -821,7 +914,7 @@ module JSON
|
|
|
821
914
|
#
|
|
822
915
|
# See method #parse.
|
|
823
916
|
#
|
|
824
|
-
#
|
|
917
|
+
# pkg:gem/json#lib/json/common.rb:390
|
|
825
918
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
|
826
919
|
|
|
827
920
|
# :call-seq:
|
|
@@ -832,7 +925,7 @@ module JSON
|
|
|
832
925
|
#
|
|
833
926
|
# See method #parse!
|
|
834
927
|
#
|
|
835
|
-
#
|
|
928
|
+
# pkg:gem/json#lib/json/common.rb:401
|
|
836
929
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
|
837
930
|
|
|
838
931
|
# :call-seq:
|
|
@@ -863,17 +956,17 @@ module JSON
|
|
|
863
956
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
|
864
957
|
#
|
|
865
958
|
# Parses nested JSON objects:
|
|
866
|
-
# source =
|
|
867
|
-
#
|
|
868
|
-
#
|
|
869
|
-
#
|
|
870
|
-
#
|
|
871
|
-
#
|
|
872
|
-
#
|
|
873
|
-
#
|
|
874
|
-
#
|
|
875
|
-
#
|
|
876
|
-
#
|
|
959
|
+
# source = <<~JSON
|
|
960
|
+
# {
|
|
961
|
+
# "name": "Dave",
|
|
962
|
+
# "age" :40,
|
|
963
|
+
# "hats": [
|
|
964
|
+
# "Cattleman's",
|
|
965
|
+
# "Panama",
|
|
966
|
+
# "Tophat"
|
|
967
|
+
# ]
|
|
968
|
+
# }
|
|
969
|
+
# JSON
|
|
877
970
|
# ruby = JSON.parse(source)
|
|
878
971
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
879
972
|
#
|
|
@@ -883,7 +976,7 @@ module JSON
|
|
|
883
976
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
|
884
977
|
# JSON.parse('')
|
|
885
978
|
#
|
|
886
|
-
#
|
|
979
|
+
# pkg:gem/json#lib/json/common.rb:353
|
|
887
980
|
def parse(source, opts = T.unsafe(nil)); end
|
|
888
981
|
|
|
889
982
|
# :call-seq:
|
|
@@ -898,7 +991,7 @@ module JSON
|
|
|
898
991
|
# which disables checking for nesting depth.
|
|
899
992
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
|
900
993
|
#
|
|
901
|
-
#
|
|
994
|
+
# pkg:gem/json#lib/json/common.rb:375
|
|
902
995
|
def parse!(source, opts = T.unsafe(nil)); end
|
|
903
996
|
|
|
904
997
|
# :call-seq:
|
|
@@ -931,29 +1024,155 @@ module JSON
|
|
|
931
1024
|
# }
|
|
932
1025
|
# }
|
|
933
1026
|
#
|
|
934
|
-
#
|
|
1027
|
+
# pkg:gem/json#lib/json/common.rb:509
|
|
935
1028
|
def pretty_generate(obj, opts = T.unsafe(nil)); end
|
|
936
1029
|
|
|
1030
|
+
# pkg:gem/json#lib/json/common.rb:987
|
|
1031
|
+
def pretty_unparse(*_arg0, **_arg1, &_arg2); end
|
|
1032
|
+
|
|
1033
|
+
# pkg:gem/json#lib/json/common.rb:997
|
|
1034
|
+
def restore(*_arg0, **_arg1, &_arg2); end
|
|
1035
|
+
|
|
937
1036
|
# :stopdoc:
|
|
938
|
-
#
|
|
1037
|
+
# All these were meant to be deprecated circa 2009, but were just set as undocumented
|
|
1038
|
+
# so usage still exist in the wild.
|
|
939
1039
|
#
|
|
940
|
-
#
|
|
941
|
-
def
|
|
1040
|
+
# pkg:gem/json#lib/json/common.rb:967
|
|
1041
|
+
def unparse(*_arg0, **_arg1, &_arg2); end
|
|
942
1042
|
|
|
943
|
-
#
|
|
1043
|
+
# :call-seq:
|
|
1044
|
+
# JSON.unsafe_load(source, options = {}) -> object
|
|
1045
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
|
944
1046
|
#
|
|
945
|
-
# source
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
#
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
# :
|
|
952
|
-
#
|
|
953
|
-
#
|
|
1047
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
|
1048
|
+
#
|
|
1049
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
1050
|
+
# like from your own database server or clients under your control, it could
|
|
1051
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
1052
|
+
#
|
|
1053
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
|
1054
|
+
# - If +source+ responds to instance method +to_str+,
|
|
1055
|
+
# <tt>source.to_str</tt> becomes the source.
|
|
1056
|
+
# - If +source+ responds to instance method +to_io+,
|
|
1057
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
|
1058
|
+
# - If +source+ responds to instance method +read+,
|
|
1059
|
+
# <tt>source.read</tt> becomes the source.
|
|
1060
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
|
1061
|
+
# - Option +allow_blank+ specifies a truthy value.
|
|
1062
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
|
1063
|
+
# - Otherwise, +source+ remains the source.
|
|
1064
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
|
1065
|
+
# It will be called recursively with each result (depth-first order).
|
|
1066
|
+
# See details below.
|
|
1067
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
|
1068
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
|
1069
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
|
1070
|
+
#
|
|
1071
|
+
# ---
|
|
1072
|
+
#
|
|
1073
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
|
1074
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
|
1075
|
+
#
|
|
1076
|
+
# Source for following examples:
|
|
1077
|
+
# source = <<~JSON
|
|
1078
|
+
# {
|
|
1079
|
+
# "name": "Dave",
|
|
1080
|
+
# "age" :40,
|
|
1081
|
+
# "hats": [
|
|
1082
|
+
# "Cattleman's",
|
|
1083
|
+
# "Panama",
|
|
1084
|
+
# "Tophat"
|
|
1085
|
+
# ]
|
|
1086
|
+
# }
|
|
1087
|
+
# JSON
|
|
1088
|
+
#
|
|
1089
|
+
# Load a \String:
|
|
1090
|
+
# ruby = JSON.unsafe_load(source)
|
|
1091
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1092
|
+
#
|
|
1093
|
+
# Load an \IO object:
|
|
1094
|
+
# require 'stringio'
|
|
1095
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
|
1096
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1097
|
+
#
|
|
1098
|
+
# Load a \File object:
|
|
1099
|
+
# path = 't.json'
|
|
1100
|
+
# File.write(path, source)
|
|
1101
|
+
# File.open(path) do |file|
|
|
1102
|
+
# JSON.unsafe_load(file)
|
|
1103
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1104
|
+
#
|
|
1105
|
+
# ---
|
|
1106
|
+
#
|
|
1107
|
+
# When +proc+ is given:
|
|
1108
|
+
# - Modifies +source+ as above.
|
|
1109
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
|
1110
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
|
1111
|
+
# - Returns the final result.
|
|
1112
|
+
#
|
|
1113
|
+
# Example:
|
|
1114
|
+
# require 'json'
|
|
1115
|
+
#
|
|
1116
|
+
# # Some classes for the example.
|
|
1117
|
+
# class Base
|
|
1118
|
+
# def initialize(attributes)
|
|
1119
|
+
# @attributes = attributes
|
|
1120
|
+
# end
|
|
1121
|
+
# end
|
|
1122
|
+
# class User < Base; end
|
|
1123
|
+
# class Account < Base; end
|
|
1124
|
+
# class Admin < Base; end
|
|
1125
|
+
# # The JSON source.
|
|
1126
|
+
# json = <<-EOF
|
|
1127
|
+
# {
|
|
1128
|
+
# "users": [
|
|
1129
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
|
1130
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
|
1131
|
+
# ],
|
|
1132
|
+
# "accounts": [
|
|
1133
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
|
1134
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
|
1135
|
+
# ],
|
|
1136
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
|
1137
|
+
# }
|
|
1138
|
+
# EOF
|
|
1139
|
+
# # Deserializer method.
|
|
1140
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
|
1141
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
|
1142
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
|
1143
|
+
# end
|
|
1144
|
+
# # Call to JSON.unsafe_load
|
|
1145
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
|
1146
|
+
# case obj
|
|
1147
|
+
# when Hash
|
|
1148
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
|
1149
|
+
# when Array
|
|
1150
|
+
# obj.map! {|v| deserialize_obj v }
|
|
1151
|
+
# end
|
|
1152
|
+
# obj
|
|
1153
|
+
# })
|
|
1154
|
+
# pp ruby
|
|
1155
|
+
# Output:
|
|
1156
|
+
# {"users"=>
|
|
1157
|
+
# [#<User:0x00000000064c4c98
|
|
1158
|
+
# @attributes=
|
|
1159
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
|
1160
|
+
# #<User:0x00000000064c4bd0
|
|
1161
|
+
# @attributes=
|
|
1162
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
|
1163
|
+
# "accounts"=>
|
|
1164
|
+
# [{"account"=>
|
|
1165
|
+
# #<Account:0x00000000064c4928
|
|
1166
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
|
1167
|
+
# {"account"=>
|
|
1168
|
+
# #<Account:0x00000000064c4680
|
|
1169
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
|
1170
|
+
# "admins"=>
|
|
1171
|
+
# #<Admin:0x00000000064c41f8
|
|
1172
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
|
954
1173
|
#
|
|
955
|
-
#
|
|
956
|
-
def
|
|
1174
|
+
# pkg:gem/json#lib/json/common.rb:685
|
|
1175
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
|
957
1176
|
|
|
958
1177
|
class << self
|
|
959
1178
|
# :call-seq:
|
|
@@ -968,35 +1187,33 @@ module JSON
|
|
|
968
1187
|
# ruby = [0, 1, nil]
|
|
969
1188
|
# JSON[ruby] # => '[0,1,null]'
|
|
970
1189
|
#
|
|
971
|
-
#
|
|
1190
|
+
# pkg:gem/json#lib/json/common.rb:132
|
|
972
1191
|
def [](object, opts = T.unsafe(nil)); end
|
|
973
1192
|
|
|
974
|
-
#
|
|
975
|
-
def
|
|
1193
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1194
|
+
def _dump_default_options; end
|
|
1195
|
+
|
|
1196
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1197
|
+
def _load_default_options; end
|
|
1198
|
+
|
|
1199
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1200
|
+
def _unsafe_load_default_options; end
|
|
976
1201
|
|
|
977
1202
|
# Returns the current create identifier.
|
|
978
1203
|
# See also JSON.create_id=.
|
|
979
1204
|
#
|
|
980
|
-
#
|
|
1205
|
+
# pkg:gem/json#lib/json/common.rb:236
|
|
981
1206
|
def create_id; end
|
|
982
1207
|
|
|
983
1208
|
# Sets create identifier, which is used to decide if the _json_create_
|
|
984
1209
|
# hook of a class should be called; initial value is +json_class+:
|
|
985
1210
|
# JSON.create_id # => 'json_class'
|
|
986
1211
|
#
|
|
987
|
-
#
|
|
1212
|
+
# pkg:gem/json#lib/json/common.rb:230
|
|
988
1213
|
def create_id=(new_value); end
|
|
989
1214
|
|
|
990
|
-
#
|
|
991
|
-
def
|
|
992
|
-
|
|
993
|
-
# Return the constant located at _path_. The format of _path_ has to be
|
|
994
|
-
# either ::A::B::C or A::B::C. In any case, A has to be located at the top
|
|
995
|
-
# level (absolute namespace path?). If there doesn't exist a constant at
|
|
996
|
-
# the given path, an ArgumentError is raised.
|
|
997
|
-
#
|
|
998
|
-
# source://json//json/common.rb#42
|
|
999
|
-
def deep_const_get(path); end
|
|
1215
|
+
# pkg:gem/json#lib/json/common.rb:104
|
|
1216
|
+
def deprecation_warning(message, uplevel = T.unsafe(nil)); end
|
|
1000
1217
|
|
|
1001
1218
|
# :call-seq:
|
|
1002
1219
|
# JSON.dump(obj, io = nil, limit = nil)
|
|
@@ -1026,24 +1243,14 @@ module JSON
|
|
|
1026
1243
|
# Output:
|
|
1027
1244
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
|
1028
1245
|
#
|
|
1029
|
-
#
|
|
1030
|
-
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
|
|
1246
|
+
# pkg:gem/json#lib/json/common.rb:932
|
|
1247
|
+
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
|
1031
1248
|
|
|
1032
|
-
#
|
|
1033
|
-
# Initially:
|
|
1034
|
-
# opts = JSON.dump_default_options
|
|
1035
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
|
|
1036
|
-
#
|
|
1037
|
-
# source://json//json/common.rb#596
|
|
1249
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1038
1250
|
def dump_default_options; end
|
|
1039
1251
|
|
|
1040
|
-
#
|
|
1041
|
-
|
|
1042
|
-
# opts = JSON.dump_default_options
|
|
1043
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
|
|
1044
|
-
#
|
|
1045
|
-
# source://json//json/common.rb#596
|
|
1046
|
-
def dump_default_options=(_arg0); end
|
|
1252
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1253
|
+
def dump_default_options=(val); end
|
|
1047
1254
|
|
|
1048
1255
|
# :call-seq:
|
|
1049
1256
|
# JSON.fast_generate(obj, opts) -> new_string
|
|
@@ -1059,21 +1266,18 @@ module JSON
|
|
|
1059
1266
|
# # Raises SystemStackError (stack level too deep):
|
|
1060
1267
|
# JSON.fast_generate(a)
|
|
1061
1268
|
#
|
|
1062
|
-
#
|
|
1269
|
+
# pkg:gem/json#lib/json/common.rb:462
|
|
1063
1270
|
def fast_generate(obj, opts = T.unsafe(nil)); end
|
|
1064
1271
|
|
|
1065
|
-
# :
|
|
1066
|
-
|
|
1067
|
-
#
|
|
1068
|
-
# source://json//json/common.rb#335
|
|
1069
|
-
def fast_unparse(obj, opts = T.unsafe(nil)); end
|
|
1272
|
+
# pkg:gem/json#lib/json/common.rb:977
|
|
1273
|
+
def fast_unparse(*_arg0, **_arg1, &_arg2); end
|
|
1070
1274
|
|
|
1071
1275
|
# :call-seq:
|
|
1072
1276
|
# JSON.generate(obj, opts = nil) -> new_string
|
|
1073
1277
|
#
|
|
1074
1278
|
# Returns a \String containing the generated \JSON data.
|
|
1075
1279
|
#
|
|
1076
|
-
# See also JSON.
|
|
1280
|
+
# See also JSON.pretty_generate.
|
|
1077
1281
|
#
|
|
1078
1282
|
# Argument +obj+ is the Ruby object to be converted to \JSON.
|
|
1079
1283
|
#
|
|
@@ -1104,31 +1308,35 @@ module JSON
|
|
|
1104
1308
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
|
1105
1309
|
# JSON.generate(a)
|
|
1106
1310
|
#
|
|
1107
|
-
#
|
|
1311
|
+
# pkg:gem/json#lib/json/common.rb:441
|
|
1108
1312
|
def generate(obj, opts = T.unsafe(nil)); end
|
|
1109
1313
|
|
|
1110
|
-
# Returns the JSON generator module that is used by JSON.
|
|
1111
|
-
# either JSON::Ext::Generator or JSON::Pure::Generator:
|
|
1112
|
-
# JSON.generator # => JSON::Ext::Generator
|
|
1314
|
+
# Returns the JSON generator module that is used by JSON.
|
|
1113
1315
|
#
|
|
1114
|
-
#
|
|
1316
|
+
# pkg:gem/json#lib/json/common.rb:179
|
|
1115
1317
|
def generator; end
|
|
1116
1318
|
|
|
1117
1319
|
# Set the module _generator_ to be used by JSON.
|
|
1118
1320
|
#
|
|
1119
|
-
#
|
|
1321
|
+
# pkg:gem/json#lib/json/common.rb:156
|
|
1120
1322
|
def generator=(generator); end
|
|
1121
1323
|
|
|
1122
|
-
# Encodes string using String.encode.
|
|
1123
|
-
#
|
|
1124
|
-
# source://json//json/common.rb#653
|
|
1125
|
-
def iconv(to, from, string); end
|
|
1126
|
-
|
|
1127
1324
|
# :call-seq:
|
|
1325
|
+
# JSON.load(source, options = {}) -> object
|
|
1128
1326
|
# JSON.load(source, proc = nil, options = {}) -> object
|
|
1129
1327
|
#
|
|
1130
1328
|
# Returns the Ruby objects created by parsing the given +source+.
|
|
1131
1329
|
#
|
|
1330
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
1331
|
+
# like from your own database server or clients under your control, it could
|
|
1332
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
1333
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
|
1334
|
+
#
|
|
1335
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
|
1336
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
|
1337
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
|
1338
|
+
# by default.
|
|
1339
|
+
#
|
|
1132
1340
|
# - Argument +source+ must be, or be convertible to, a \String:
|
|
1133
1341
|
# - If +source+ responds to instance method +to_str+,
|
|
1134
1342
|
# <tt>source.to_str</tt> becomes the source.
|
|
@@ -1143,9 +1351,6 @@ module JSON
|
|
|
1143
1351
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
|
1144
1352
|
# It will be called recursively with each result (depth-first order).
|
|
1145
1353
|
# See details below.
|
|
1146
|
-
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
1147
|
-
# like from your own database server or clients under your control, it could
|
|
1148
|
-
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
1149
1354
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
|
1150
1355
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
|
1151
1356
|
# The default options can be changed via method JSON.load_default_options=.
|
|
@@ -1156,17 +1361,17 @@ module JSON
|
|
|
1156
1361
|
# <tt>parse(source, opts)</tt>; see #parse.
|
|
1157
1362
|
#
|
|
1158
1363
|
# Source for following examples:
|
|
1159
|
-
# source =
|
|
1160
|
-
#
|
|
1161
|
-
#
|
|
1162
|
-
#
|
|
1163
|
-
#
|
|
1164
|
-
#
|
|
1165
|
-
#
|
|
1166
|
-
#
|
|
1167
|
-
#
|
|
1168
|
-
#
|
|
1169
|
-
#
|
|
1364
|
+
# source = <<~JSON
|
|
1365
|
+
# {
|
|
1366
|
+
# "name": "Dave",
|
|
1367
|
+
# "age" :40,
|
|
1368
|
+
# "hats": [
|
|
1369
|
+
# "Cattleman's",
|
|
1370
|
+
# "Panama",
|
|
1371
|
+
# "Tophat"
|
|
1372
|
+
# ]
|
|
1373
|
+
# }
|
|
1374
|
+
# JSON
|
|
1170
1375
|
#
|
|
1171
1376
|
# Load a \String:
|
|
1172
1377
|
# ruby = JSON.load(source)
|
|
@@ -1231,6 +1436,7 @@ module JSON
|
|
|
1231
1436
|
# when Array
|
|
1232
1437
|
# obj.map! {|v| deserialize_obj v }
|
|
1233
1438
|
# end
|
|
1439
|
+
# obj
|
|
1234
1440
|
# })
|
|
1235
1441
|
# pp ruby
|
|
1236
1442
|
# Output:
|
|
@@ -1252,24 +1458,14 @@ module JSON
|
|
|
1252
1458
|
# #<Admin:0x00000000064c41f8
|
|
1253
1459
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
|
1254
1460
|
#
|
|
1255
|
-
#
|
|
1461
|
+
# pkg:gem/json#lib/json/common.rb:856
|
|
1256
1462
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
|
1257
1463
|
|
|
1258
|
-
#
|
|
1259
|
-
# Initially:
|
|
1260
|
-
# opts = JSON.load_default_options
|
|
1261
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
|
1262
|
-
#
|
|
1263
|
-
# source://json//json/common.rb#420
|
|
1464
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1264
1465
|
def load_default_options; end
|
|
1265
1466
|
|
|
1266
|
-
#
|
|
1267
|
-
|
|
1268
|
-
# opts = JSON.load_default_options
|
|
1269
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
|
1270
|
-
#
|
|
1271
|
-
# source://json//json/common.rb#420
|
|
1272
|
-
def load_default_options=(_arg0); end
|
|
1467
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1468
|
+
def load_default_options=(val); end
|
|
1273
1469
|
|
|
1274
1470
|
# :call-seq:
|
|
1275
1471
|
# JSON.load_file(path, opts={}) -> object
|
|
@@ -1279,7 +1475,7 @@ module JSON
|
|
|
1279
1475
|
#
|
|
1280
1476
|
# See method #parse.
|
|
1281
1477
|
#
|
|
1282
|
-
#
|
|
1478
|
+
# pkg:gem/json#lib/json/common.rb:390
|
|
1283
1479
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
|
1284
1480
|
|
|
1285
1481
|
# :call-seq:
|
|
@@ -1290,7 +1486,7 @@ module JSON
|
|
|
1290
1486
|
#
|
|
1291
1487
|
# See method #parse!
|
|
1292
1488
|
#
|
|
1293
|
-
#
|
|
1489
|
+
# pkg:gem/json#lib/json/common.rb:401
|
|
1294
1490
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
|
1295
1491
|
|
|
1296
1492
|
# :call-seq:
|
|
@@ -1321,17 +1517,17 @@ module JSON
|
|
|
1321
1517
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
|
1322
1518
|
#
|
|
1323
1519
|
# Parses nested JSON objects:
|
|
1324
|
-
# source =
|
|
1325
|
-
#
|
|
1326
|
-
#
|
|
1327
|
-
#
|
|
1328
|
-
#
|
|
1329
|
-
#
|
|
1330
|
-
#
|
|
1331
|
-
#
|
|
1332
|
-
#
|
|
1333
|
-
#
|
|
1334
|
-
#
|
|
1520
|
+
# source = <<~JSON
|
|
1521
|
+
# {
|
|
1522
|
+
# "name": "Dave",
|
|
1523
|
+
# "age" :40,
|
|
1524
|
+
# "hats": [
|
|
1525
|
+
# "Cattleman's",
|
|
1526
|
+
# "Panama",
|
|
1527
|
+
# "Tophat"
|
|
1528
|
+
# ]
|
|
1529
|
+
# }
|
|
1530
|
+
# JSON
|
|
1335
1531
|
# ruby = JSON.parse(source)
|
|
1336
1532
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1337
1533
|
#
|
|
@@ -1341,7 +1537,7 @@ module JSON
|
|
|
1341
1537
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
|
1342
1538
|
# JSON.parse('')
|
|
1343
1539
|
#
|
|
1344
|
-
#
|
|
1540
|
+
# pkg:gem/json#lib/json/common.rb:353
|
|
1345
1541
|
def parse(source, opts = T.unsafe(nil)); end
|
|
1346
1542
|
|
|
1347
1543
|
# :call-seq:
|
|
@@ -1356,19 +1552,17 @@ module JSON
|
|
|
1356
1552
|
# which disables checking for nesting depth.
|
|
1357
1553
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
|
1358
1554
|
#
|
|
1359
|
-
#
|
|
1555
|
+
# pkg:gem/json#lib/json/common.rb:375
|
|
1360
1556
|
def parse!(source, opts = T.unsafe(nil)); end
|
|
1361
1557
|
|
|
1362
|
-
# Returns the JSON parser class that is used by JSON.
|
|
1363
|
-
# JSON::Ext::Parser or JSON::Pure::Parser:
|
|
1364
|
-
# JSON.parser # => JSON::Ext::Parser
|
|
1558
|
+
# Returns the JSON parser class that is used by JSON.
|
|
1365
1559
|
#
|
|
1366
|
-
#
|
|
1560
|
+
# pkg:gem/json#lib/json/common.rb:146
|
|
1367
1561
|
def parser; end
|
|
1368
1562
|
|
|
1369
1563
|
# Set the JSON parser class _parser_ to be used by JSON.
|
|
1370
1564
|
#
|
|
1371
|
-
#
|
|
1565
|
+
# pkg:gem/json#lib/json/common.rb:149
|
|
1372
1566
|
def parser=(parser); end
|
|
1373
1567
|
|
|
1374
1568
|
# :call-seq:
|
|
@@ -1401,111 +1595,579 @@ module JSON
|
|
|
1401
1595
|
# }
|
|
1402
1596
|
# }
|
|
1403
1597
|
#
|
|
1404
|
-
#
|
|
1598
|
+
# pkg:gem/json#lib/json/common.rb:509
|
|
1405
1599
|
def pretty_generate(obj, opts = T.unsafe(nil)); end
|
|
1406
1600
|
|
|
1407
|
-
# :
|
|
1408
|
-
|
|
1409
|
-
#
|
|
1410
|
-
# source://json//json/common.rb#390
|
|
1411
|
-
def pretty_unparse(obj, opts = T.unsafe(nil)); end
|
|
1412
|
-
|
|
1413
|
-
# Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
|
|
1414
|
-
#
|
|
1415
|
-
# source://json//json/common.rb#575
|
|
1416
|
-
def recurse_proc(result, &proc); end
|
|
1601
|
+
# pkg:gem/json#lib/json/common.rb:987
|
|
1602
|
+
def pretty_unparse(*_arg0, **_arg1, &_arg2); end
|
|
1417
1603
|
|
|
1418
|
-
#
|
|
1419
|
-
def restore(
|
|
1604
|
+
# pkg:gem/json#lib/json/common.rb:997
|
|
1605
|
+
def restore(*_arg0, **_arg1, &_arg2); end
|
|
1420
1606
|
|
|
1421
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
|
1422
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
|
1423
|
-
# JSON.state # => JSON::Ext::Generator::State
|
|
1607
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
|
1424
1608
|
#
|
|
1425
|
-
#
|
|
1609
|
+
# pkg:gem/json#lib/json/common.rb:182
|
|
1426
1610
|
def state; end
|
|
1427
1611
|
|
|
1428
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
|
1429
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
|
1430
|
-
# JSON.state # => JSON::Ext::Generator::State
|
|
1612
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
|
1431
1613
|
#
|
|
1432
|
-
#
|
|
1614
|
+
# pkg:gem/json#lib/json/common.rb:182
|
|
1433
1615
|
def state=(_arg0); end
|
|
1434
1616
|
|
|
1435
1617
|
# :stopdoc:
|
|
1436
|
-
#
|
|
1437
|
-
#
|
|
1618
|
+
# All these were meant to be deprecated circa 2009, but were just set as undocumented
|
|
1619
|
+
# so usage still exist in the wild.
|
|
1620
|
+
#
|
|
1621
|
+
# pkg:gem/json#lib/json/common.rb:967
|
|
1622
|
+
def unparse(*_arg0, **_arg1, &_arg2); end
|
|
1623
|
+
|
|
1624
|
+
# :call-seq:
|
|
1625
|
+
# JSON.unsafe_load(source, options = {}) -> object
|
|
1626
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
|
1627
|
+
#
|
|
1628
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
|
1629
|
+
#
|
|
1630
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
|
1631
|
+
# like from your own database server or clients under your control, it could
|
|
1632
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
|
1438
1633
|
#
|
|
1439
|
-
# source
|
|
1440
|
-
|
|
1634
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
|
1635
|
+
# - If +source+ responds to instance method +to_str+,
|
|
1636
|
+
# <tt>source.to_str</tt> becomes the source.
|
|
1637
|
+
# - If +source+ responds to instance method +to_io+,
|
|
1638
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
|
1639
|
+
# - If +source+ responds to instance method +read+,
|
|
1640
|
+
# <tt>source.read</tt> becomes the source.
|
|
1641
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
|
1642
|
+
# - Option +allow_blank+ specifies a truthy value.
|
|
1643
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
|
1644
|
+
# - Otherwise, +source+ remains the source.
|
|
1645
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
|
1646
|
+
# It will be called recursively with each result (depth-first order).
|
|
1647
|
+
# See details below.
|
|
1648
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
|
1649
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
|
1650
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
|
1651
|
+
#
|
|
1652
|
+
# ---
|
|
1653
|
+
#
|
|
1654
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
|
1655
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
|
1656
|
+
#
|
|
1657
|
+
# Source for following examples:
|
|
1658
|
+
# source = <<~JSON
|
|
1659
|
+
# {
|
|
1660
|
+
# "name": "Dave",
|
|
1661
|
+
# "age" :40,
|
|
1662
|
+
# "hats": [
|
|
1663
|
+
# "Cattleman's",
|
|
1664
|
+
# "Panama",
|
|
1665
|
+
# "Tophat"
|
|
1666
|
+
# ]
|
|
1667
|
+
# }
|
|
1668
|
+
# JSON
|
|
1669
|
+
#
|
|
1670
|
+
# Load a \String:
|
|
1671
|
+
# ruby = JSON.unsafe_load(source)
|
|
1672
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1673
|
+
#
|
|
1674
|
+
# Load an \IO object:
|
|
1675
|
+
# require 'stringio'
|
|
1676
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
|
1677
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1678
|
+
#
|
|
1679
|
+
# Load a \File object:
|
|
1680
|
+
# path = 't.json'
|
|
1681
|
+
# File.write(path, source)
|
|
1682
|
+
# File.open(path) do |file|
|
|
1683
|
+
# JSON.unsafe_load(file)
|
|
1684
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
|
1685
|
+
#
|
|
1686
|
+
# ---
|
|
1687
|
+
#
|
|
1688
|
+
# When +proc+ is given:
|
|
1689
|
+
# - Modifies +source+ as above.
|
|
1690
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
|
1691
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
|
1692
|
+
# - Returns the final result.
|
|
1693
|
+
#
|
|
1694
|
+
# Example:
|
|
1695
|
+
# require 'json'
|
|
1696
|
+
#
|
|
1697
|
+
# # Some classes for the example.
|
|
1698
|
+
# class Base
|
|
1699
|
+
# def initialize(attributes)
|
|
1700
|
+
# @attributes = attributes
|
|
1701
|
+
# end
|
|
1702
|
+
# end
|
|
1703
|
+
# class User < Base; end
|
|
1704
|
+
# class Account < Base; end
|
|
1705
|
+
# class Admin < Base; end
|
|
1706
|
+
# # The JSON source.
|
|
1707
|
+
# json = <<-EOF
|
|
1708
|
+
# {
|
|
1709
|
+
# "users": [
|
|
1710
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
|
1711
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
|
1712
|
+
# ],
|
|
1713
|
+
# "accounts": [
|
|
1714
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
|
1715
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
|
1716
|
+
# ],
|
|
1717
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
|
1718
|
+
# }
|
|
1719
|
+
# EOF
|
|
1720
|
+
# # Deserializer method.
|
|
1721
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
|
1722
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
|
1723
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
|
1724
|
+
# end
|
|
1725
|
+
# # Call to JSON.unsafe_load
|
|
1726
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
|
1727
|
+
# case obj
|
|
1728
|
+
# when Hash
|
|
1729
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
|
1730
|
+
# when Array
|
|
1731
|
+
# obj.map! {|v| deserialize_obj v }
|
|
1732
|
+
# end
|
|
1733
|
+
# obj
|
|
1734
|
+
# })
|
|
1735
|
+
# pp ruby
|
|
1736
|
+
# Output:
|
|
1737
|
+
# {"users"=>
|
|
1738
|
+
# [#<User:0x00000000064c4c98
|
|
1739
|
+
# @attributes=
|
|
1740
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
|
1741
|
+
# #<User:0x00000000064c4bd0
|
|
1742
|
+
# @attributes=
|
|
1743
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
|
1744
|
+
# "accounts"=>
|
|
1745
|
+
# [{"account"=>
|
|
1746
|
+
# #<Account:0x00000000064c4928
|
|
1747
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
|
1748
|
+
# {"account"=>
|
|
1749
|
+
# #<Account:0x00000000064c4680
|
|
1750
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
|
1751
|
+
# "admins"=>
|
|
1752
|
+
# #<Admin:0x00000000064c41f8
|
|
1753
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
|
1754
|
+
#
|
|
1755
|
+
# pkg:gem/json#lib/json/common.rb:685
|
|
1756
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
|
1757
|
+
|
|
1758
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1759
|
+
def unsafe_load_default_options; end
|
|
1760
|
+
|
|
1761
|
+
# pkg:gem/json#lib/json/common.rb:208
|
|
1762
|
+
def unsafe_load_default_options=(val); end
|
|
1763
|
+
|
|
1764
|
+
private
|
|
1765
|
+
|
|
1766
|
+
# pkg:gem/json#lib/json/common.rb:1010
|
|
1767
|
+
def const_missing(const_name); end
|
|
1768
|
+
|
|
1769
|
+
# pkg:gem/json#lib/json/common.rb:205
|
|
1770
|
+
def deprecated_singleton_attr_accessor(*attrs); end
|
|
1771
|
+
|
|
1772
|
+
# Called from the extension when a hash has both string and symbol keys
|
|
1773
|
+
#
|
|
1774
|
+
# pkg:gem/json#lib/json/common.rb:187
|
|
1775
|
+
def on_mixed_keys_hash(hash, do_raise); end
|
|
1441
1776
|
end
|
|
1442
1777
|
end
|
|
1443
1778
|
|
|
1444
|
-
#
|
|
1445
|
-
|
|
1779
|
+
# JSON::Coder holds a parser and generator configuration.
|
|
1780
|
+
#
|
|
1781
|
+
# module MyApp
|
|
1782
|
+
# JSONC_CODER = JSON::Coder.new(
|
|
1783
|
+
# allow_trailing_comma: true
|
|
1784
|
+
# )
|
|
1785
|
+
# end
|
|
1786
|
+
#
|
|
1787
|
+
# MyApp::JSONC_CODER.load(document)
|
|
1788
|
+
#
|
|
1789
|
+
# pkg:gem/json#lib/json/common.rb:1036
|
|
1790
|
+
class JSON::Coder
|
|
1791
|
+
# :call-seq:
|
|
1792
|
+
# JSON.new(options = nil, &block)
|
|
1793
|
+
#
|
|
1794
|
+
# Argument +options+, if given, contains a \Hash of options for both parsing and generating.
|
|
1795
|
+
# See {Parsing Options}[rdoc-ref:JSON@Parsing+Options],
|
|
1796
|
+
# and {Generating Options}[rdoc-ref:JSON@Generating+Options].
|
|
1797
|
+
#
|
|
1798
|
+
# For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
|
|
1799
|
+
# encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
|
|
1800
|
+
# \JSON counterpart:
|
|
1801
|
+
#
|
|
1802
|
+
# module MyApp
|
|
1803
|
+
# API_JSON_CODER = JSON::Coder.new do |object|
|
|
1804
|
+
# case object
|
|
1805
|
+
# when Time
|
|
1806
|
+
# object.iso8601(3)
|
|
1807
|
+
# else
|
|
1808
|
+
# object # Unknown type, will raise
|
|
1809
|
+
# end
|
|
1810
|
+
# end
|
|
1811
|
+
# end
|
|
1812
|
+
#
|
|
1813
|
+
# puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
|
|
1814
|
+
#
|
|
1815
|
+
# pkg:gem/json#lib/json/common.rb:1061
|
|
1816
|
+
def initialize(options = T.unsafe(nil), &as_json); end
|
|
1446
1817
|
|
|
1447
|
-
#
|
|
1448
|
-
|
|
1818
|
+
# call-seq:
|
|
1819
|
+
# dump(object) -> String
|
|
1820
|
+
# dump(object, io) -> io
|
|
1821
|
+
#
|
|
1822
|
+
# Serialize the given object into a \JSON document.
|
|
1823
|
+
#
|
|
1824
|
+
# pkg:gem/json#lib/json/common.rb:1079
|
|
1825
|
+
def dump(object, io = T.unsafe(nil)); end
|
|
1826
|
+
|
|
1827
|
+
# pkg:gem/json#lib/json/common.rb:1082
|
|
1828
|
+
def generate(object, io = T.unsafe(nil)); end
|
|
1449
1829
|
|
|
1450
|
-
|
|
1451
|
-
#
|
|
1452
|
-
|
|
1830
|
+
# call-seq:
|
|
1831
|
+
# load(string) -> Object
|
|
1832
|
+
#
|
|
1833
|
+
# Parse the given \JSON document and return an equivalent Ruby object.
|
|
1834
|
+
#
|
|
1835
|
+
# pkg:gem/json#lib/json/common.rb:1088
|
|
1836
|
+
def load(source); end
|
|
1453
1837
|
|
|
1454
|
-
#
|
|
1838
|
+
# call-seq:
|
|
1839
|
+
# load(path) -> Object
|
|
1840
|
+
#
|
|
1841
|
+
# Parse the given \JSON document and return an equivalent Ruby object.
|
|
1842
|
+
#
|
|
1843
|
+
# pkg:gem/json#lib/json/common.rb:1097
|
|
1844
|
+
def load_file(path); end
|
|
1845
|
+
|
|
1846
|
+
# pkg:gem/json#lib/json/common.rb:1091
|
|
1847
|
+
def parse(source); end
|
|
1848
|
+
end
|
|
1849
|
+
|
|
1850
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1851
|
+
class JSON::Ext::Generator::State
|
|
1852
|
+
# call-seq: new(opts = {})
|
|
1853
|
+
#
|
|
1854
|
+
# Instantiates a new State object, configured by _opts_.
|
|
1855
|
+
#
|
|
1856
|
+
# Argument +opts+, if given, contains a \Hash of options for the generation.
|
|
1857
|
+
# See {Generating Options}[rdoc-ref:JSON@Generating+Options].
|
|
1858
|
+
#
|
|
1859
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1860
|
+
def initialize(opts = T.unsafe(nil)); end
|
|
1861
|
+
|
|
1862
|
+
# call-seq: [](name)
|
|
1863
|
+
#
|
|
1864
|
+
# Returns the value returned by method +name+.
|
|
1865
|
+
#
|
|
1866
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:77
|
|
1867
|
+
def [](name); end
|
|
1868
|
+
|
|
1869
|
+
# call-seq: []=(name, value)
|
|
1870
|
+
#
|
|
1871
|
+
# Sets the attribute name to value.
|
|
1872
|
+
#
|
|
1873
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:91
|
|
1874
|
+
def []=(name, value); end
|
|
1875
|
+
|
|
1876
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1877
|
+
def _generate_no_fallback(*_arg0); end
|
|
1878
|
+
|
|
1879
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1880
|
+
def allow_nan=(_arg0); end
|
|
1881
|
+
|
|
1882
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1883
|
+
def allow_nan?; end
|
|
1884
|
+
|
|
1885
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1886
|
+
def array_nl; end
|
|
1887
|
+
|
|
1888
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1889
|
+
def array_nl=(_arg0); end
|
|
1890
|
+
|
|
1891
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1892
|
+
def as_json; end
|
|
1893
|
+
|
|
1894
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1895
|
+
def as_json=(_arg0); end
|
|
1896
|
+
|
|
1897
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1898
|
+
def ascii_only=(_arg0); end
|
|
1899
|
+
|
|
1900
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1901
|
+
def ascii_only?; end
|
|
1902
|
+
|
|
1903
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1904
|
+
def buffer_initial_length; end
|
|
1905
|
+
|
|
1906
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1907
|
+
def buffer_initial_length=(_arg0); end
|
|
1908
|
+
|
|
1909
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1910
|
+
def check_circular?; end
|
|
1911
|
+
|
|
1912
|
+
# call-seq: configure(opts)
|
|
1913
|
+
#
|
|
1914
|
+
# Configure this State instance with the Hash _opts_, and return
|
|
1915
|
+
# itself.
|
|
1916
|
+
#
|
|
1917
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:23
|
|
1918
|
+
def configure(opts); end
|
|
1919
|
+
|
|
1920
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1921
|
+
def depth; end
|
|
1922
|
+
|
|
1923
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1924
|
+
def depth=(_arg0); end
|
|
1925
|
+
|
|
1926
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1927
|
+
def escape_slash; end
|
|
1928
|
+
|
|
1929
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1930
|
+
def escape_slash=(_arg0); end
|
|
1931
|
+
|
|
1932
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1933
|
+
def escape_slash?; end
|
|
1934
|
+
|
|
1935
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1936
|
+
def generate(*_arg0); end
|
|
1937
|
+
|
|
1938
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1939
|
+
def indent; end
|
|
1940
|
+
|
|
1941
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1942
|
+
def indent=(_arg0); end
|
|
1943
|
+
|
|
1944
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1945
|
+
def max_nesting; end
|
|
1946
|
+
|
|
1947
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1948
|
+
def max_nesting=(_arg0); end
|
|
1949
|
+
|
|
1950
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:36
|
|
1951
|
+
def merge(opts); end
|
|
1952
|
+
|
|
1953
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1954
|
+
def object_nl; end
|
|
1955
|
+
|
|
1956
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1957
|
+
def object_nl=(_arg0); end
|
|
1958
|
+
|
|
1959
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1960
|
+
def script_safe; end
|
|
1961
|
+
|
|
1962
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1963
|
+
def script_safe=(_arg0); end
|
|
1964
|
+
|
|
1965
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1966
|
+
def script_safe?; end
|
|
1967
|
+
|
|
1968
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1969
|
+
def space; end
|
|
1970
|
+
|
|
1971
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1972
|
+
def space=(_arg0); end
|
|
1973
|
+
|
|
1974
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1975
|
+
def space_before; end
|
|
1976
|
+
|
|
1977
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1978
|
+
def space_before=(_arg0); end
|
|
1979
|
+
|
|
1980
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1981
|
+
def strict; end
|
|
1982
|
+
|
|
1983
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1984
|
+
def strict=(_arg0); end
|
|
1985
|
+
|
|
1986
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
1987
|
+
def strict?; end
|
|
1988
|
+
|
|
1989
|
+
# call-seq: to_h
|
|
1990
|
+
#
|
|
1991
|
+
# Returns the configuration instance variables as a hash, that can be
|
|
1992
|
+
# passed to the configure method.
|
|
1993
|
+
#
|
|
1994
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:42
|
|
1995
|
+
def to_h; end
|
|
1996
|
+
|
|
1997
|
+
# pkg:gem/json#lib/json/ext/generator/state.rb:72
|
|
1455
1998
|
def to_hash; end
|
|
1456
1999
|
|
|
1457
|
-
|
|
1458
|
-
|
|
2000
|
+
private
|
|
2001
|
+
|
|
2002
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2003
|
+
def _configure(_arg0); end
|
|
1459
2004
|
|
|
1460
|
-
#
|
|
1461
|
-
def
|
|
2005
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2006
|
+
def allow_duplicate_key?; end
|
|
2007
|
+
|
|
2008
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2009
|
+
def initialize_copy(_arg0); end
|
|
1462
2010
|
|
|
1463
2011
|
class << self
|
|
1464
|
-
#
|
|
1465
|
-
def
|
|
2012
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2013
|
+
def _generate_no_fallback(_arg0, _arg1, _arg2); end
|
|
1466
2014
|
|
|
1467
|
-
#
|
|
1468
|
-
def
|
|
2015
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2016
|
+
def from_state(_arg0); end
|
|
1469
2017
|
|
|
1470
|
-
#
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
# source://json//json/generic_object.rb#13
|
|
1475
|
-
def json_creatable=(_arg0); end
|
|
2018
|
+
# pkg:gem/json#lib/json/ext.rb:39
|
|
2019
|
+
def generate(_arg0, _arg1, _arg2); end
|
|
2020
|
+
end
|
|
2021
|
+
end
|
|
1476
2022
|
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
2023
|
+
# pkg:gem/json#lib/json/ext.rb:9
|
|
2024
|
+
class JSON::Ext::Parser
|
|
2025
|
+
# pkg:gem/json#lib/json/ext.rb:17
|
|
2026
|
+
def initialize(source, opts = T.unsafe(nil)); end
|
|
2027
|
+
|
|
2028
|
+
# pkg:gem/json#lib/json/ext.rb:26
|
|
2029
|
+
def parse; end
|
|
1481
2030
|
|
|
1482
|
-
|
|
1483
|
-
|
|
2031
|
+
# pkg:gem/json#lib/json/ext.rb:22
|
|
2032
|
+
def source; end
|
|
1484
2033
|
|
|
1485
|
-
|
|
1486
|
-
|
|
2034
|
+
class << self
|
|
2035
|
+
# pkg:gem/json#lib/json/ext.rb:11
|
|
2036
|
+
def parse(_arg0, _arg1); end
|
|
1487
2037
|
end
|
|
1488
2038
|
end
|
|
1489
2039
|
|
|
1490
|
-
#
|
|
1491
|
-
|
|
2040
|
+
# pkg:gem/json#lib/json/ext.rb:32
|
|
2041
|
+
JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
|
|
2042
|
+
|
|
2043
|
+
# pkg:gem/json#lib/json/ext.rb:31
|
|
2044
|
+
class JSON::Ext::ParserConfig
|
|
2045
|
+
# pkg:gem/json#lib/json/ext.rb:31
|
|
2046
|
+
def initialize(_arg0); end
|
|
2047
|
+
|
|
2048
|
+
# pkg:gem/json#lib/json/ext.rb:31
|
|
2049
|
+
def parse(_arg0); end
|
|
2050
|
+
end
|
|
2051
|
+
|
|
2052
|
+
# Fragment of JSON document that is to be included as is:
|
|
2053
|
+
# fragment = JSON::Fragment.new("[1, 2, 3]")
|
|
2054
|
+
# JSON.generate({ count: 3, items: fragments })
|
|
2055
|
+
#
|
|
2056
|
+
# This allows to easily assemble multiple JSON fragments that have
|
|
2057
|
+
# been persisted somewhere without having to parse them nor resorting
|
|
2058
|
+
# to string interpolation.
|
|
2059
|
+
#
|
|
2060
|
+
# Note: no validation is performed on the provided string. It is the
|
|
2061
|
+
# responsibility of the caller to ensure the string contains valid JSON.
|
|
2062
|
+
#
|
|
2063
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2064
|
+
class JSON::Fragment < ::Struct
|
|
2065
|
+
# pkg:gem/json#lib/json/common.rb:290
|
|
2066
|
+
def initialize(json); end
|
|
2067
|
+
|
|
2068
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2069
|
+
def json; end
|
|
2070
|
+
|
|
2071
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2072
|
+
def json=(_); end
|
|
2073
|
+
|
|
2074
|
+
# pkg:gem/json#lib/json/common.rb:298
|
|
2075
|
+
def to_json(state = T.unsafe(nil), *_arg1); end
|
|
2076
|
+
|
|
1492
2077
|
class << self
|
|
1493
|
-
#
|
|
1494
|
-
def
|
|
2078
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2079
|
+
def [](*_arg0); end
|
|
2080
|
+
|
|
2081
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2082
|
+
def inspect; end
|
|
2083
|
+
|
|
2084
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2085
|
+
def keyword_init?; end
|
|
2086
|
+
|
|
2087
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2088
|
+
def members; end
|
|
2089
|
+
|
|
2090
|
+
# pkg:gem/json#lib/json/common.rb:289
|
|
2091
|
+
def new(*_arg0); end
|
|
1495
2092
|
end
|
|
1496
2093
|
end
|
|
1497
2094
|
|
|
1498
|
-
#
|
|
1499
|
-
|
|
2095
|
+
# This exception is raised if a generator or unparser error occurs.
|
|
2096
|
+
#
|
|
2097
|
+
# pkg:gem/json#lib/json/common.rb:259
|
|
2098
|
+
class JSON::GeneratorError < ::JSON::JSONError
|
|
2099
|
+
# pkg:gem/json#lib/json/common.rb:262
|
|
2100
|
+
def initialize(message, invalid_object = T.unsafe(nil)); end
|
|
1500
2101
|
|
|
1501
|
-
#
|
|
1502
|
-
|
|
2102
|
+
# pkg:gem/json#lib/json/common.rb:267
|
|
2103
|
+
def detailed_message(*_arg0, **_arg1, &_arg2); end
|
|
2104
|
+
|
|
2105
|
+
# pkg:gem/json#lib/json/common.rb:260
|
|
2106
|
+
def invalid_object; end
|
|
2107
|
+
end
|
|
2108
|
+
|
|
2109
|
+
# pkg:gem/json#lib/json/common.rb:1102
|
|
2110
|
+
module JSON::GeneratorMethods
|
|
2111
|
+
# call-seq: to_json(*)
|
|
2112
|
+
#
|
|
2113
|
+
# Converts this object into a JSON string.
|
|
2114
|
+
# If this object doesn't directly maps to a JSON native type,
|
|
2115
|
+
# first convert it to a string (calling #to_s), then converts
|
|
2116
|
+
# it to a JSON string, and returns the result.
|
|
2117
|
+
# This is a fallback, if no special method #to_json was defined for some object.
|
|
2118
|
+
#
|
|
2119
|
+
# pkg:gem/json#lib/json/common.rb:1110
|
|
2120
|
+
def to_json(state = T.unsafe(nil), *_arg1); end
|
|
2121
|
+
end
|
|
1503
2122
|
|
|
1504
|
-
#
|
|
2123
|
+
# pkg:gem/json#lib/json/common.rb:358
|
|
2124
|
+
JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
|
|
2125
|
+
|
|
2126
|
+
# pkg:gem/json#lib/json/common.rb:471
|
|
2127
|
+
JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
|
|
2128
|
+
|
|
2129
|
+
# pkg:gem/json#lib/json/common.rb:152
|
|
2130
|
+
JSON::Parser = JSON::Ext::Parser
|
|
2131
|
+
|
|
2132
|
+
# This exception is raised if a parser error occurs.
|
|
1505
2133
|
#
|
|
1506
|
-
#
|
|
1507
|
-
JSON::
|
|
2134
|
+
# pkg:gem/json#lib/json/common.rb:250
|
|
2135
|
+
class JSON::ParserError < ::JSON::JSONError
|
|
2136
|
+
# pkg:gem/json#lib/json/common.rb:251
|
|
2137
|
+
def column; end
|
|
1508
2138
|
|
|
2139
|
+
# pkg:gem/json#lib/json/common.rb:251
|
|
2140
|
+
def line; end
|
|
2141
|
+
end
|
|
2142
|
+
|
|
2143
|
+
# pkg:gem/json#lib/json/common.rb:8
|
|
2144
|
+
module JSON::ParserOptions
|
|
2145
|
+
class << self
|
|
2146
|
+
# pkg:gem/json#lib/json/common.rb:10
|
|
2147
|
+
def prepare(opts); end
|
|
2148
|
+
|
|
2149
|
+
private
|
|
2150
|
+
|
|
2151
|
+
# pkg:gem/json#lib/json/common.rb:40
|
|
2152
|
+
def array_class_proc(array_class, on_load); end
|
|
2153
|
+
|
|
2154
|
+
# TODO: extract :create_additions support to another gem for version 3.0
|
|
2155
|
+
#
|
|
2156
|
+
# pkg:gem/json#lib/json/common.rb:52
|
|
2157
|
+
def create_additions_proc(opts); end
|
|
2158
|
+
|
|
2159
|
+
# pkg:gem/json#lib/json/common.rb:95
|
|
2160
|
+
def create_additions_warning; end
|
|
2161
|
+
|
|
2162
|
+
# pkg:gem/json#lib/json/common.rb:29
|
|
2163
|
+
def object_class_proc(object_class, on_load); end
|
|
2164
|
+
end
|
|
2165
|
+
end
|
|
2166
|
+
|
|
2167
|
+
# pkg:gem/json#lib/json/common.rb:173
|
|
2168
|
+
JSON::State = JSON::Ext::Generator::State
|
|
2169
|
+
|
|
2170
|
+
# pkg:gem/json#lib/json/common.rb:1127
|
|
1509
2171
|
module Kernel
|
|
1510
2172
|
private
|
|
1511
2173
|
|
|
@@ -1516,18 +2178,25 @@ module Kernel
|
|
|
1516
2178
|
# The _opts_ argument is passed through to generate/parse respectively. See
|
|
1517
2179
|
# generate and parse for their documentation.
|
|
1518
2180
|
#
|
|
1519
|
-
#
|
|
1520
|
-
def JSON(object,
|
|
2181
|
+
# pkg:gem/json#lib/json/common.rb:1166
|
|
2182
|
+
def JSON(object, opts = T.unsafe(nil)); end
|
|
1521
2183
|
|
|
1522
2184
|
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
|
1523
2185
|
# one line.
|
|
1524
2186
|
#
|
|
1525
|
-
#
|
|
2187
|
+
# pkg:gem/json#lib/json/common.rb:1132
|
|
1526
2188
|
def j(*objs); end
|
|
1527
2189
|
|
|
1528
2190
|
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
|
1529
2191
|
# indentation and over many lines.
|
|
1530
2192
|
#
|
|
1531
|
-
#
|
|
2193
|
+
# pkg:gem/json#lib/json/common.rb:1147
|
|
1532
2194
|
def jj(*objs); end
|
|
1533
2195
|
end
|
|
2196
|
+
|
|
2197
|
+
# pkg:gem/json#lib/json/common.rb:1171
|
|
2198
|
+
class Object < ::BasicObject
|
|
2199
|
+
include ::Kernel
|
|
2200
|
+
include ::PP::ObjectMixin
|
|
2201
|
+
include ::JSON::GeneratorMethods
|
|
2202
|
+
end
|