lunchmoney 1.4.0 → 1.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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/build_and_publish_yard_docs.yml +4 -4
- data/.github/workflows/ci.yml +9 -10
- data/.github/workflows/rbi-updater.yml +1 -1
- data/.github/workflows/release_pipeline.yml +1 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/.simplecov +1 -0
- data/.toys/.toys.rb +8 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +102 -78
- data/README.md +0 -2
- data/SECURITY.md +151 -0
- data/bin/check_vcr_version +94 -0
- data/lib/lunchmoney/api.rb +26 -38
- data/lib/lunchmoney/calls/assets.rb +10 -13
- data/lib/lunchmoney/calls/base.rb +59 -7
- data/lib/lunchmoney/calls/budgets.rb +22 -25
- data/lib/lunchmoney/calls/categories.rb +28 -38
- data/lib/lunchmoney/calls/crypto.rb +7 -9
- data/lib/lunchmoney/calls/plaid_accounts.rb +7 -9
- data/lib/lunchmoney/calls/recurring_expenses.rb +4 -5
- data/lib/lunchmoney/calls/tags.rb +3 -4
- data/lib/lunchmoney/calls/transactions.rb +28 -37
- data/lib/lunchmoney/calls/users.rb +3 -4
- data/lib/lunchmoney/configuration.rb +20 -0
- data/lib/lunchmoney/deprecate.rb +35 -0
- data/lib/lunchmoney/objects/asset.rb +6 -1
- data/lib/lunchmoney/objects/object.rb +4 -9
- data/lib/lunchmoney/objects/plaid_account.rb +6 -1
- data/lib/lunchmoney/validators.rb +8 -6
- data/lib/lunchmoney/version.rb +1 -1
- data/lib/lunchmoney.rb +3 -3
- data/lunchmoney.gemspec +1 -1
- data/sorbet/rbi/annotations/activesupport.rbi +40 -0
- data/sorbet/rbi/dsl/active_support/callbacks.rbi +0 -2
- data/sorbet/rbi/gems/{activesupport@7.2.1.rbi → activesupport@8.0.2.1.rbi} +1431 -1028
- data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +4 -3
- data/sorbet/rbi/gems/{base64@0.2.0.rbi → base64@0.3.0.rbi} +76 -39
- data/sorbet/rbi/gems/benchmark@0.4.1.rbi +619 -0
- data/sorbet/rbi/gems/bigdecimal@3.2.2.rbi +275 -0
- data/sorbet/rbi/gems/{concurrent-ruby@1.3.4.rbi → concurrent-ruby@1.3.5.rbi} +44 -32
- data/sorbet/rbi/gems/{connection_pool@2.4.1.rbi → connection_pool@2.5.3.rbi} +1 -0
- data/sorbet/rbi/gems/{dotenv@3.1.2.rbi → dotenv@3.1.8.rbi} +21 -29
- data/sorbet/rbi/gems/{drb@2.2.1.rbi → drb@2.2.3.rbi} +503 -188
- data/sorbet/rbi/gems/{erubi@1.13.0.rbi → erubi@1.13.1.rbi} +14 -9
- data/sorbet/rbi/gems/{faraday-net_http@3.1.1.rbi → faraday-net_http@3.4.1.rbi} +34 -34
- data/sorbet/rbi/gems/{faraday@2.10.1.rbi → faraday@2.13.4.rbi} +507 -171
- data/sorbet/rbi/gems/{hashdiff@1.1.1.rbi → hashdiff@1.2.0.rbi} +5 -3
- data/sorbet/rbi/gems/{i18n@1.14.5.rbi → i18n@1.14.7.rbi} +80 -80
- data/sorbet/rbi/gems/{json@2.7.2.rbi → json@2.13.2.rbi} +988 -226
- data/sorbet/rbi/gems/{kramdown@2.4.0.rbi → kramdown@2.5.1.rbi} +316 -234
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
- data/sorbet/rbi/gems/{logger@1.6.0.rbi → logger@1.7.0.rbi} +136 -76
- data/sorbet/rbi/gems/{minitest@5.25.1.rbi → minitest@5.25.5.rbi} +227 -220
- data/sorbet/rbi/gems/{mocha@2.4.5.rbi → mocha@2.7.1.rbi} +154 -118
- data/sorbet/rbi/gems/{net-http@0.4.1.rbi → net-http@0.6.0.rbi} +360 -181
- data/sorbet/rbi/gems/{parser@3.3.4.2.rbi → parser@3.3.9.0.rbi} +326 -308
- data/sorbet/rbi/gems/{prism@0.30.0.rbi → prism@1.4.0.rbi} +12440 -9920
- data/sorbet/rbi/gems/{rack@3.1.7.rbi → rack@3.2.1.rbi} +752 -579
- data/sorbet/rbi/gems/{rake@13.2.1.rbi → rake@13.3.0.rbi} +238 -227
- data/sorbet/rbi/gems/rbi@0.3.6.rbi +5162 -0
- data/sorbet/rbi/gems/rbs@4.0.0.dev.4.rbi +7895 -0
- data/sorbet/rbi/gems/{regexp_parser@2.9.2.rbi → regexp_parser@2.11.2.rbi} +1124 -1013
- data/sorbet/rbi/gems/require-hooks@0.2.2.rbi +110 -0
- data/sorbet/rbi/gems/{rexml@3.3.6.rbi → rexml@3.4.2.rbi} +755 -318
- data/sorbet/rbi/gems/{rubocop-ast@1.32.1.rbi → rubocop-ast@1.46.0.rbi} +1287 -899
- data/sorbet/rbi/gems/{rubocop-minitest@0.35.1.rbi → rubocop-minitest@0.38.2.rbi} +133 -97
- data/sorbet/rbi/gems/{rubocop-rails@2.26.0.rbi → rubocop-rails@2.33.3.rbi} +9874 -6597
- data/sorbet/rbi/gems/{rubocop-shopify@2.15.1.rbi → rubocop-shopify@2.17.1.rbi} +1 -0
- data/sorbet/rbi/gems/{rubocop-sorbet@0.8.5.rbi → rubocop-sorbet@0.10.5.rbi} +804 -83
- data/sorbet/rbi/gems/{rubocop@1.65.1.rbi → rubocop@1.80.1.rbi} +10688 -5103
- data/sorbet/rbi/gems/{securerandom@0.3.1.rbi → securerandom@0.4.1.rbi} +7 -5
- data/sorbet/rbi/gems/{spoom@1.4.2.rbi → spoom@1.7.6.rbi} +1939 -1039
- data/sorbet/rbi/gems/{tapioca@0.16.1.rbi → tapioca@0.17.7.rbi} +765 -821
- data/sorbet/rbi/gems/{thor@1.3.1.rbi → thor@1.4.0.rbi} +139 -91
- data/sorbet/rbi/gems/unicode-display_width@3.1.5.rbi +132 -0
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
- data/sorbet/rbi/gems/{uri@0.13.0.rbi → uri@1.0.3.rbi} +278 -256
- data/sorbet/rbi/gems/{vcr@6.3.1.rbi → vcr@6.3.1-ce35c236fe48899f02ddf780973b44cdb756c0ee.rbi} +140 -123
- data/sorbet/rbi/gems/{webmock@3.23.1.rbi → webmock@3.25.1.rbi} +101 -78
- data/sorbet/rbi/gems/{yard@0.9.36.rbi → yard@0.9.37.rbi} +394 -235
- metadata +55 -53
- data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +0 -78
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +0 -14237
- data/sorbet/rbi/gems/rbi@0.1.14.rbi +0 -3305
- data/sorbet/rbi/gems/strscan@3.1.0.rbi +0 -9
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +0 -65
- /data/sorbet/rbi/gems/{parallel@1.26.3.rbi → parallel@1.27.0.rbi} +0 -0
@@ -4,19 +4,27 @@
|
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
|
8
|
+
class Array
|
9
|
+
include ::Enumerable
|
10
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Array
|
11
|
+
end
|
12
|
+
|
13
|
+
class FalseClass
|
14
|
+
include ::JSON::Ext::Generator::GeneratorMethods::FalseClass
|
15
|
+
end
|
16
|
+
|
17
|
+
class Float < ::Numeric
|
18
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Float
|
19
|
+
end
|
20
|
+
|
21
|
+
class Hash
|
22
|
+
include ::Enumerable
|
23
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Hash
|
24
|
+
end
|
25
|
+
|
26
|
+
class Integer < ::Numeric
|
27
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Integer
|
20
28
|
end
|
21
29
|
|
22
30
|
# = JavaScript \Object Notation (\JSON)
|
@@ -144,6 +152,24 @@ end
|
|
144
152
|
#
|
145
153
|
# ---
|
146
154
|
#
|
155
|
+
# Option +allow_duplicate_key+ specifies whether duplicate keys in objects
|
156
|
+
# should be ignored or cause an error to be raised:
|
157
|
+
#
|
158
|
+
# When not specified:
|
159
|
+
# # The last value is used and a deprecation warning emitted.
|
160
|
+
# JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
|
161
|
+
# # waring: detected duplicate keys in JSON object.
|
162
|
+
# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
|
163
|
+
#
|
164
|
+
# When set to `+true+`
|
165
|
+
# # The last value is used.
|
166
|
+
# JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
|
167
|
+
#
|
168
|
+
# When set to `+false+`, the future default:
|
169
|
+
# JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
|
170
|
+
#
|
171
|
+
# ---
|
172
|
+
#
|
147
173
|
# Option +allow_nan+ (boolean) specifies whether to allow
|
148
174
|
# NaN, Infinity, and MinusInfinity in +source+;
|
149
175
|
# defaults to +false+.
|
@@ -160,8 +186,23 @@ end
|
|
160
186
|
# ruby = JSON.parse(source, {allow_nan: true})
|
161
187
|
# ruby # => [NaN, Infinity, -Infinity]
|
162
188
|
#
|
189
|
+
# ---
|
190
|
+
#
|
191
|
+
# Option +allow_trailing_comma+ (boolean) specifies whether to allow
|
192
|
+
# trailing commas in objects and arrays;
|
193
|
+
# defaults to +false+.
|
194
|
+
#
|
195
|
+
# With the default, +false+:
|
196
|
+
# JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
|
197
|
+
#
|
198
|
+
# When enabled:
|
199
|
+
# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
|
200
|
+
#
|
163
201
|
# ====== Output Options
|
164
202
|
#
|
203
|
+
# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
|
204
|
+
# defaults to +false+.
|
205
|
+
#
|
165
206
|
# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
|
166
207
|
# should be Symbols;
|
167
208
|
# defaults to +false+ (use Strings).
|
@@ -395,13 +436,13 @@ end
|
|
395
436
|
# json1 = JSON.generate(ruby)
|
396
437
|
# ruby1 = JSON.parse(json1, create_additions: true)
|
397
438
|
# # Make a nice display.
|
398
|
-
# display =
|
399
|
-
#
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
439
|
+
# display = <<~EOT
|
440
|
+
# Generated JSON:
|
441
|
+
# Without addition: #{json0} (#{json0.class})
|
442
|
+
# With addition: #{json1} (#{json1.class})
|
443
|
+
# Parsed JSON:
|
444
|
+
# Without addition: #{ruby0.inspect} (#{ruby0.class})
|
445
|
+
# With addition: #{ruby1.inspect} (#{ruby1.class})
|
405
446
|
# EOT
|
406
447
|
# puts display
|
407
448
|
#
|
@@ -579,13 +620,13 @@ end
|
|
579
620
|
# json1 = JSON.generate(foo1)
|
580
621
|
# obj1 = JSON.parse(json1, create_additions: true)
|
581
622
|
# # Make a nice display.
|
582
|
-
# display =
|
583
|
-
#
|
584
|
-
#
|
585
|
-
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
623
|
+
# display = <<~EOT
|
624
|
+
# Generated JSON:
|
625
|
+
# Without custom addition: #{json0} (#{json0.class})
|
626
|
+
# With custom addition: #{json1} (#{json1.class})
|
627
|
+
# Parsed JSON:
|
628
|
+
# Without custom addition: #{obj0.inspect} (#{obj0.class})
|
629
|
+
# With custom addition: #{obj1.inspect} (#{obj1.class})
|
589
630
|
# EOT
|
590
631
|
# puts display
|
591
632
|
#
|
@@ -598,7 +639,7 @@ end
|
|
598
639
|
# Without custom addition: "#<Foo:0x0000000006534e80>" (String)
|
599
640
|
# With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
|
600
641
|
#
|
601
|
-
# source://json//lib/json/version.rb#
|
642
|
+
# source://json//lib/json/version.rb#3
|
602
643
|
module JSON
|
603
644
|
private
|
604
645
|
|
@@ -630,7 +671,7 @@ module JSON
|
|
630
671
|
# Output:
|
631
672
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
632
673
|
#
|
633
|
-
# source://json//lib/json/common.rb#
|
674
|
+
# source://json//lib/json/common.rb#893
|
634
675
|
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
635
676
|
|
636
677
|
# :call-seq:
|
@@ -647,14 +688,11 @@ module JSON
|
|
647
688
|
# # Raises SystemStackError (stack level too deep):
|
648
689
|
# JSON.fast_generate(a)
|
649
690
|
#
|
650
|
-
# source://json//lib/json/common.rb#
|
691
|
+
# source://json//lib/json/common.rb#446
|
651
692
|
def fast_generate(obj, opts = T.unsafe(nil)); end
|
652
693
|
|
653
|
-
#
|
654
|
-
|
655
|
-
#
|
656
|
-
# source://json//lib/json/common.rb#329
|
657
|
-
def fast_unparse(obj, opts = T.unsafe(nil)); end
|
694
|
+
# source://json//lib/json/common.rb#938
|
695
|
+
def fast_unparse(*_arg0, **_arg1, &_arg2); end
|
658
696
|
|
659
697
|
# :call-seq:
|
660
698
|
# JSON.generate(obj, opts = nil) -> new_string
|
@@ -692,7 +730,7 @@ module JSON
|
|
692
730
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
693
731
|
# JSON.generate(a)
|
694
732
|
#
|
695
|
-
# source://json//lib/json/common.rb#
|
733
|
+
# source://json//lib/json/common.rb#425
|
696
734
|
def generate(obj, opts = T.unsafe(nil)); end
|
697
735
|
|
698
736
|
# :call-seq:
|
@@ -700,6 +738,16 @@ module JSON
|
|
700
738
|
#
|
701
739
|
# Returns the Ruby objects created by parsing the given +source+.
|
702
740
|
#
|
741
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
742
|
+
# like from your own database server or clients under your control, it could
|
743
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
744
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
745
|
+
#
|
746
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
747
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
748
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
749
|
+
# by default.
|
750
|
+
#
|
703
751
|
# - Argument +source+ must be, or be convertible to, a \String:
|
704
752
|
# - If +source+ responds to instance method +to_str+,
|
705
753
|
# <tt>source.to_str</tt> becomes the source.
|
@@ -714,9 +762,6 @@ module JSON
|
|
714
762
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
715
763
|
# It will be called recursively with each result (depth-first order).
|
716
764
|
# See details below.
|
717
|
-
# BEWARE: This method is meant to serialise data from trusted user input,
|
718
|
-
# like from your own database server or clients under your control, it could
|
719
|
-
# be dangerous to allow untrusted users to pass JSON sources into it.
|
720
765
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
721
766
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
722
767
|
# The default options can be changed via method JSON.load_default_options=.
|
@@ -727,17 +772,17 @@ module JSON
|
|
727
772
|
# <tt>parse(source, opts)</tt>; see #parse.
|
728
773
|
#
|
729
774
|
# Source for following examples:
|
730
|
-
# source =
|
731
|
-
#
|
732
|
-
#
|
733
|
-
#
|
734
|
-
#
|
735
|
-
#
|
736
|
-
#
|
737
|
-
#
|
738
|
-
#
|
739
|
-
#
|
740
|
-
#
|
775
|
+
# source = <<~JSON
|
776
|
+
# {
|
777
|
+
# "name": "Dave",
|
778
|
+
# "age" :40,
|
779
|
+
# "hats": [
|
780
|
+
# "Cattleman's",
|
781
|
+
# "Panama",
|
782
|
+
# "Tophat"
|
783
|
+
# ]
|
784
|
+
# }
|
785
|
+
# JSON
|
741
786
|
#
|
742
787
|
# Load a \String:
|
743
788
|
# ruby = JSON.load(source)
|
@@ -823,7 +868,7 @@ module JSON
|
|
823
868
|
# #<Admin:0x00000000064c41f8
|
824
869
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
825
870
|
#
|
826
|
-
# source://json//lib/json/common.rb#
|
871
|
+
# source://json//lib/json/common.rb#827
|
827
872
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
828
873
|
|
829
874
|
# :call-seq:
|
@@ -834,7 +879,7 @@ module JSON
|
|
834
879
|
#
|
835
880
|
# See method #parse.
|
836
881
|
#
|
837
|
-
# source://json//lib/json/common.rb#
|
882
|
+
# source://json//lib/json/common.rb#374
|
838
883
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
839
884
|
|
840
885
|
# :call-seq:
|
@@ -845,12 +890,9 @@ module JSON
|
|
845
890
|
#
|
846
891
|
# See method #parse!
|
847
892
|
#
|
848
|
-
# source://json//lib/json/common.rb#
|
893
|
+
# source://json//lib/json/common.rb#385
|
849
894
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
850
895
|
|
851
|
-
# source://json//lib/json/common.rb#643
|
852
|
-
def merge_dump_options(opts, strict: T.unsafe(nil)); end
|
853
|
-
|
854
896
|
# :call-seq:
|
855
897
|
# JSON.parse(source, opts) -> object
|
856
898
|
#
|
@@ -879,17 +921,17 @@ module JSON
|
|
879
921
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
880
922
|
#
|
881
923
|
# Parses nested JSON objects:
|
882
|
-
# source =
|
883
|
-
#
|
884
|
-
#
|
885
|
-
#
|
886
|
-
#
|
887
|
-
#
|
888
|
-
#
|
889
|
-
#
|
890
|
-
#
|
891
|
-
#
|
892
|
-
#
|
924
|
+
# source = <<~JSON
|
925
|
+
# {
|
926
|
+
# "name": "Dave",
|
927
|
+
# "age" :40,
|
928
|
+
# "hats": [
|
929
|
+
# "Cattleman's",
|
930
|
+
# "Panama",
|
931
|
+
# "Tophat"
|
932
|
+
# ]
|
933
|
+
# }
|
934
|
+
# JSON
|
893
935
|
# ruby = JSON.parse(source)
|
894
936
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
895
937
|
#
|
@@ -899,7 +941,7 @@ module JSON
|
|
899
941
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
900
942
|
# JSON.parse('')
|
901
943
|
#
|
902
|
-
# source://json//lib/json/common.rb#
|
944
|
+
# source://json//lib/json/common.rb#337
|
903
945
|
def parse(source, opts = T.unsafe(nil)); end
|
904
946
|
|
905
947
|
# :call-seq:
|
@@ -914,7 +956,7 @@ module JSON
|
|
914
956
|
# which disables checking for nesting depth.
|
915
957
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
916
958
|
#
|
917
|
-
# source://json//lib/json/common.rb#
|
959
|
+
# source://json//lib/json/common.rb#359
|
918
960
|
def parse!(source, opts = T.unsafe(nil)); end
|
919
961
|
|
920
962
|
# :call-seq:
|
@@ -947,29 +989,153 @@ module JSON
|
|
947
989
|
# }
|
948
990
|
# }
|
949
991
|
#
|
950
|
-
# source://json//lib/json/common.rb#
|
992
|
+
# source://json//lib/json/common.rb#493
|
951
993
|
def pretty_generate(obj, opts = T.unsafe(nil)); end
|
952
994
|
|
995
|
+
# source://json//lib/json/common.rb#948
|
996
|
+
def pretty_unparse(*_arg0, **_arg1, &_arg2); end
|
997
|
+
|
998
|
+
# source://json//lib/json/common.rb#958
|
999
|
+
def restore(*_arg0, **_arg1, &_arg2); end
|
1000
|
+
|
953
1001
|
# :stopdoc:
|
954
|
-
#
|
1002
|
+
# All these were meant to be deprecated circa 2009, but were just set as undocumented
|
1003
|
+
# so usage still exist in the wild.
|
955
1004
|
#
|
956
|
-
# source://json//lib/json/common.rb#
|
957
|
-
def
|
1005
|
+
# source://json//lib/json/common.rb#928
|
1006
|
+
def unparse(*_arg0, **_arg1, &_arg2); end
|
958
1007
|
|
959
|
-
#
|
1008
|
+
# :call-seq:
|
1009
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
960
1010
|
#
|
961
|
-
# source
|
962
|
-
|
963
|
-
|
964
|
-
#
|
965
|
-
|
966
|
-
|
967
|
-
# :stopdoc:
|
968
|
-
# I want to deprecate these later, so I'll first be silent about them, and
|
969
|
-
# later delete them.
|
1011
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
1012
|
+
#
|
1013
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
1014
|
+
# like from your own database server or clients under your control, it could
|
1015
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
970
1016
|
#
|
971
|
-
# source
|
972
|
-
|
1017
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
1018
|
+
# - If +source+ responds to instance method +to_str+,
|
1019
|
+
# <tt>source.to_str</tt> becomes the source.
|
1020
|
+
# - If +source+ responds to instance method +to_io+,
|
1021
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
1022
|
+
# - If +source+ responds to instance method +read+,
|
1023
|
+
# <tt>source.read</tt> becomes the source.
|
1024
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
1025
|
+
# - Option +allow_blank+ specifies a truthy value.
|
1026
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
1027
|
+
# - Otherwise, +source+ remains the source.
|
1028
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1029
|
+
# It will be called recursively with each result (depth-first order).
|
1030
|
+
# See details below.
|
1031
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1032
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1033
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
1034
|
+
#
|
1035
|
+
# ---
|
1036
|
+
#
|
1037
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
1038
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
1039
|
+
#
|
1040
|
+
# Source for following examples:
|
1041
|
+
# source = <<~JSON
|
1042
|
+
# {
|
1043
|
+
# "name": "Dave",
|
1044
|
+
# "age" :40,
|
1045
|
+
# "hats": [
|
1046
|
+
# "Cattleman's",
|
1047
|
+
# "Panama",
|
1048
|
+
# "Tophat"
|
1049
|
+
# ]
|
1050
|
+
# }
|
1051
|
+
# JSON
|
1052
|
+
#
|
1053
|
+
# Load a \String:
|
1054
|
+
# ruby = JSON.unsafe_load(source)
|
1055
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1056
|
+
#
|
1057
|
+
# Load an \IO object:
|
1058
|
+
# require 'stringio'
|
1059
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
1060
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1061
|
+
#
|
1062
|
+
# Load a \File object:
|
1063
|
+
# path = 't.json'
|
1064
|
+
# File.write(path, source)
|
1065
|
+
# File.open(path) do |file|
|
1066
|
+
# JSON.unsafe_load(file)
|
1067
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1068
|
+
#
|
1069
|
+
# ---
|
1070
|
+
#
|
1071
|
+
# When +proc+ is given:
|
1072
|
+
# - Modifies +source+ as above.
|
1073
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
1074
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
1075
|
+
# - Returns the final result.
|
1076
|
+
#
|
1077
|
+
# Example:
|
1078
|
+
# require 'json'
|
1079
|
+
#
|
1080
|
+
# # Some classes for the example.
|
1081
|
+
# class Base
|
1082
|
+
# def initialize(attributes)
|
1083
|
+
# @attributes = attributes
|
1084
|
+
# end
|
1085
|
+
# end
|
1086
|
+
# class User < Base; end
|
1087
|
+
# class Account < Base; end
|
1088
|
+
# class Admin < Base; end
|
1089
|
+
# # The JSON source.
|
1090
|
+
# json = <<-EOF
|
1091
|
+
# {
|
1092
|
+
# "users": [
|
1093
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
1094
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
1095
|
+
# ],
|
1096
|
+
# "accounts": [
|
1097
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
1098
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
1099
|
+
# ],
|
1100
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
1101
|
+
# }
|
1102
|
+
# EOF
|
1103
|
+
# # Deserializer method.
|
1104
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
1105
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
1106
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
1107
|
+
# end
|
1108
|
+
# # Call to JSON.unsafe_load
|
1109
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
1110
|
+
# case obj
|
1111
|
+
# when Hash
|
1112
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
1113
|
+
# when Array
|
1114
|
+
# obj.map! {|v| deserialize_obj v }
|
1115
|
+
# end
|
1116
|
+
# })
|
1117
|
+
# pp ruby
|
1118
|
+
# Output:
|
1119
|
+
# {"users"=>
|
1120
|
+
# [#<User:0x00000000064c4c98
|
1121
|
+
# @attributes=
|
1122
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
1123
|
+
# #<User:0x00000000064c4bd0
|
1124
|
+
# @attributes=
|
1125
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
1126
|
+
# "accounts"=>
|
1127
|
+
# [{"account"=>
|
1128
|
+
# #<Account:0x00000000064c4928
|
1129
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
1130
|
+
# {"account"=>
|
1131
|
+
# #<Account:0x00000000064c4680
|
1132
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
1133
|
+
# "admins"=>
|
1134
|
+
# #<Admin:0x00000000064c41f8
|
1135
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1136
|
+
#
|
1137
|
+
# source://json//lib/json/common.rb#667
|
1138
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
973
1139
|
|
974
1140
|
class << self
|
975
1141
|
# :call-seq:
|
@@ -984,36 +1150,42 @@ module JSON
|
|
984
1150
|
# ruby = [0, 1, nil]
|
985
1151
|
# JSON[ruby] # => '[0,1,null]'
|
986
1152
|
#
|
987
|
-
# source://json//lib/json/common.rb#
|
1153
|
+
# source://json//lib/json/common.rb#127
|
988
1154
|
def [](object, opts = T.unsafe(nil)); end
|
989
1155
|
|
990
|
-
# source://json//lib/json/common.rb#
|
991
|
-
def
|
1156
|
+
# source://json//lib/json/common.rb#192
|
1157
|
+
def _dump_default_options; end
|
1158
|
+
|
1159
|
+
# source://json//lib/json/common.rb#192
|
1160
|
+
def _load_default_options; end
|
1161
|
+
|
1162
|
+
# source://json//lib/json/common.rb#192
|
1163
|
+
def _unsafe_load_default_options; end
|
992
1164
|
|
993
1165
|
# Returns the current create identifier.
|
994
1166
|
# See also JSON.create_id=.
|
995
1167
|
#
|
996
|
-
# source://json//lib/json/common.rb#
|
1168
|
+
# source://json//lib/json/common.rb#220
|
997
1169
|
def create_id; end
|
998
1170
|
|
999
1171
|
# Sets create identifier, which is used to decide if the _json_create_
|
1000
1172
|
# hook of a class should be called; initial value is +json_class+:
|
1001
1173
|
# JSON.create_id # => 'json_class'
|
1002
1174
|
#
|
1003
|
-
# source://json//lib/json/common.rb#
|
1175
|
+
# source://json//lib/json/common.rb#214
|
1004
1176
|
def create_id=(new_value); end
|
1005
1177
|
|
1006
|
-
# source://json//lib/json/common.rb#95
|
1007
|
-
def create_pretty_state; end
|
1008
|
-
|
1009
1178
|
# Return the constant located at _path_. The format of _path_ has to be
|
1010
1179
|
# either ::A::B::C or A::B::C. In any case, A has to be located at the top
|
1011
1180
|
# level (absolute namespace path?). If there doesn't exist a constant at
|
1012
1181
|
# the given path, an ArgumentError is raised.
|
1013
1182
|
#
|
1014
|
-
# source://json//lib/json/common.rb#
|
1183
|
+
# source://json//lib/json/common.rb#154
|
1015
1184
|
def deep_const_get(path); end
|
1016
1185
|
|
1186
|
+
# source://json//lib/json/common.rb#99
|
1187
|
+
def deprecation_warning(message, uplevel = T.unsafe(nil)); end
|
1188
|
+
|
1017
1189
|
# :call-seq:
|
1018
1190
|
# JSON.dump(obj, io = nil, limit = nil)
|
1019
1191
|
#
|
@@ -1042,24 +1214,14 @@ module JSON
|
|
1042
1214
|
# Output:
|
1043
1215
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
1044
1216
|
#
|
1045
|
-
# source://json//lib/json/common.rb#
|
1217
|
+
# source://json//lib/json/common.rb#893
|
1046
1218
|
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
1047
1219
|
|
1048
|
-
#
|
1049
|
-
# Initially:
|
1050
|
-
# opts = JSON.dump_default_options
|
1051
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
|
1052
|
-
#
|
1053
|
-
# source://json//lib/json/common.rb#580
|
1220
|
+
# source://json//lib/json/common.rb#192
|
1054
1221
|
def dump_default_options; end
|
1055
1222
|
|
1056
|
-
#
|
1057
|
-
|
1058
|
-
# opts = JSON.dump_default_options
|
1059
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
|
1060
|
-
#
|
1061
|
-
# source://json//lib/json/common.rb#580
|
1062
|
-
def dump_default_options=(_arg0); end
|
1223
|
+
# source://json//lib/json/common.rb#192
|
1224
|
+
def dump_default_options=(val); end
|
1063
1225
|
|
1064
1226
|
# :call-seq:
|
1065
1227
|
# JSON.fast_generate(obj, opts) -> new_string
|
@@ -1075,14 +1237,11 @@ module JSON
|
|
1075
1237
|
# # Raises SystemStackError (stack level too deep):
|
1076
1238
|
# JSON.fast_generate(a)
|
1077
1239
|
#
|
1078
|
-
# source://json//lib/json/common.rb#
|
1240
|
+
# source://json//lib/json/common.rb#446
|
1079
1241
|
def fast_generate(obj, opts = T.unsafe(nil)); end
|
1080
1242
|
|
1081
|
-
#
|
1082
|
-
|
1083
|
-
#
|
1084
|
-
# source://json//lib/json/common.rb#329
|
1085
|
-
def fast_unparse(obj, opts = T.unsafe(nil)); end
|
1243
|
+
# source://json//lib/json/common.rb#938
|
1244
|
+
def fast_unparse(*_arg0, **_arg1, &_arg2); end
|
1086
1245
|
|
1087
1246
|
# :call-seq:
|
1088
1247
|
# JSON.generate(obj, opts = nil) -> new_string
|
@@ -1120,31 +1279,34 @@ module JSON
|
|
1120
1279
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
1121
1280
|
# JSON.generate(a)
|
1122
1281
|
#
|
1123
|
-
# source://json//lib/json/common.rb#
|
1282
|
+
# source://json//lib/json/common.rb#425
|
1124
1283
|
def generate(obj, opts = T.unsafe(nil)); end
|
1125
1284
|
|
1126
|
-
# Returns the JSON generator module that is used by JSON.
|
1127
|
-
# either JSON::Ext::Generator or JSON::Pure::Generator:
|
1128
|
-
# JSON.generator # => JSON::Ext::Generator
|
1285
|
+
# Returns the JSON generator module that is used by JSON.
|
1129
1286
|
#
|
1130
|
-
# source://json//lib/json/common.rb#
|
1287
|
+
# source://json//lib/json/common.rb#182
|
1131
1288
|
def generator; end
|
1132
1289
|
|
1133
1290
|
# Set the module _generator_ to be used by JSON.
|
1134
1291
|
#
|
1135
|
-
# source://json//lib/json/common.rb#
|
1292
|
+
# source://json//lib/json/common.rb#161
|
1136
1293
|
def generator=(generator); end
|
1137
1294
|
|
1138
|
-
# Encodes string using String.encode.
|
1139
|
-
#
|
1140
|
-
# source://json//lib/json/common.rb#639
|
1141
|
-
def iconv(to, from, string); end
|
1142
|
-
|
1143
1295
|
# :call-seq:
|
1144
1296
|
# JSON.load(source, proc = nil, options = {}) -> object
|
1145
1297
|
#
|
1146
1298
|
# Returns the Ruby objects created by parsing the given +source+.
|
1147
1299
|
#
|
1300
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
1301
|
+
# like from your own database server or clients under your control, it could
|
1302
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
1303
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
1304
|
+
#
|
1305
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
1306
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
1307
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
1308
|
+
# by default.
|
1309
|
+
#
|
1148
1310
|
# - Argument +source+ must be, or be convertible to, a \String:
|
1149
1311
|
# - If +source+ responds to instance method +to_str+,
|
1150
1312
|
# <tt>source.to_str</tt> becomes the source.
|
@@ -1159,9 +1321,6 @@ module JSON
|
|
1159
1321
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1160
1322
|
# It will be called recursively with each result (depth-first order).
|
1161
1323
|
# See details below.
|
1162
|
-
# BEWARE: This method is meant to serialise data from trusted user input,
|
1163
|
-
# like from your own database server or clients under your control, it could
|
1164
|
-
# be dangerous to allow untrusted users to pass JSON sources into it.
|
1165
1324
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1166
1325
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1167
1326
|
# The default options can be changed via method JSON.load_default_options=.
|
@@ -1172,17 +1331,17 @@ module JSON
|
|
1172
1331
|
# <tt>parse(source, opts)</tt>; see #parse.
|
1173
1332
|
#
|
1174
1333
|
# Source for following examples:
|
1175
|
-
# source =
|
1176
|
-
#
|
1177
|
-
#
|
1178
|
-
#
|
1179
|
-
#
|
1180
|
-
#
|
1181
|
-
#
|
1182
|
-
#
|
1183
|
-
#
|
1184
|
-
#
|
1185
|
-
#
|
1334
|
+
# source = <<~JSON
|
1335
|
+
# {
|
1336
|
+
# "name": "Dave",
|
1337
|
+
# "age" :40,
|
1338
|
+
# "hats": [
|
1339
|
+
# "Cattleman's",
|
1340
|
+
# "Panama",
|
1341
|
+
# "Tophat"
|
1342
|
+
# ]
|
1343
|
+
# }
|
1344
|
+
# JSON
|
1186
1345
|
#
|
1187
1346
|
# Load a \String:
|
1188
1347
|
# ruby = JSON.load(source)
|
@@ -1268,24 +1427,14 @@ module JSON
|
|
1268
1427
|
# #<Admin:0x00000000064c41f8
|
1269
1428
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1270
1429
|
#
|
1271
|
-
# source://json//lib/json/common.rb#
|
1430
|
+
# source://json//lib/json/common.rb#827
|
1272
1431
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1273
1432
|
|
1274
|
-
#
|
1275
|
-
# Initially:
|
1276
|
-
# opts = JSON.load_default_options
|
1277
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1278
|
-
#
|
1279
|
-
# source://json//lib/json/common.rb#404
|
1433
|
+
# source://json//lib/json/common.rb#192
|
1280
1434
|
def load_default_options; end
|
1281
1435
|
|
1282
|
-
#
|
1283
|
-
|
1284
|
-
# opts = JSON.load_default_options
|
1285
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1286
|
-
#
|
1287
|
-
# source://json//lib/json/common.rb#404
|
1288
|
-
def load_default_options=(_arg0); end
|
1436
|
+
# source://json//lib/json/common.rb#192
|
1437
|
+
def load_default_options=(val); end
|
1289
1438
|
|
1290
1439
|
# :call-seq:
|
1291
1440
|
# JSON.load_file(path, opts={}) -> object
|
@@ -1295,7 +1444,7 @@ module JSON
|
|
1295
1444
|
#
|
1296
1445
|
# See method #parse.
|
1297
1446
|
#
|
1298
|
-
# source://json//lib/json/common.rb#
|
1447
|
+
# source://json//lib/json/common.rb#374
|
1299
1448
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
1300
1449
|
|
1301
1450
|
# :call-seq:
|
@@ -1306,7 +1455,7 @@ module JSON
|
|
1306
1455
|
#
|
1307
1456
|
# See method #parse!
|
1308
1457
|
#
|
1309
|
-
# source://json//lib/json/common.rb#
|
1458
|
+
# source://json//lib/json/common.rb#385
|
1310
1459
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
1311
1460
|
|
1312
1461
|
# :call-seq:
|
@@ -1337,17 +1486,17 @@ module JSON
|
|
1337
1486
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
1338
1487
|
#
|
1339
1488
|
# Parses nested JSON objects:
|
1340
|
-
# source =
|
1341
|
-
#
|
1342
|
-
#
|
1343
|
-
#
|
1344
|
-
#
|
1345
|
-
#
|
1346
|
-
#
|
1347
|
-
#
|
1348
|
-
#
|
1349
|
-
#
|
1350
|
-
#
|
1489
|
+
# source = <<~JSON
|
1490
|
+
# {
|
1491
|
+
# "name": "Dave",
|
1492
|
+
# "age" :40,
|
1493
|
+
# "hats": [
|
1494
|
+
# "Cattleman's",
|
1495
|
+
# "Panama",
|
1496
|
+
# "Tophat"
|
1497
|
+
# ]
|
1498
|
+
# }
|
1499
|
+
# JSON
|
1351
1500
|
# ruby = JSON.parse(source)
|
1352
1501
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1353
1502
|
#
|
@@ -1357,7 +1506,7 @@ module JSON
|
|
1357
1506
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
1358
1507
|
# JSON.parse('')
|
1359
1508
|
#
|
1360
|
-
# source://json//lib/json/common.rb#
|
1509
|
+
# source://json//lib/json/common.rb#337
|
1361
1510
|
def parse(source, opts = T.unsafe(nil)); end
|
1362
1511
|
|
1363
1512
|
# :call-seq:
|
@@ -1372,19 +1521,17 @@ module JSON
|
|
1372
1521
|
# which disables checking for nesting depth.
|
1373
1522
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
1374
1523
|
#
|
1375
|
-
# source://json//lib/json/common.rb#
|
1524
|
+
# source://json//lib/json/common.rb#359
|
1376
1525
|
def parse!(source, opts = T.unsafe(nil)); end
|
1377
1526
|
|
1378
|
-
# Returns the JSON parser class that is used by JSON.
|
1379
|
-
# JSON::Ext::Parser or JSON::Pure::Parser:
|
1380
|
-
# JSON.parser # => JSON::Ext::Parser
|
1527
|
+
# Returns the JSON parser class that is used by JSON.
|
1381
1528
|
#
|
1382
|
-
# source://json//lib/json/common.rb#
|
1529
|
+
# source://json//lib/json/common.rb#141
|
1383
1530
|
def parser; end
|
1384
1531
|
|
1385
1532
|
# Set the JSON parser class _parser_ to be used by JSON.
|
1386
1533
|
#
|
1387
|
-
# source://json//lib/json/common.rb#
|
1534
|
+
# source://json//lib/json/common.rb#144
|
1388
1535
|
def parser=(parser); end
|
1389
1536
|
|
1390
1537
|
# :call-seq:
|
@@ -1417,56 +1564,621 @@ module JSON
|
|
1417
1564
|
# }
|
1418
1565
|
# }
|
1419
1566
|
#
|
1420
|
-
# source://json//lib/json/common.rb#
|
1567
|
+
# source://json//lib/json/common.rb#493
|
1421
1568
|
def pretty_generate(obj, opts = T.unsafe(nil)); end
|
1422
1569
|
|
1423
|
-
#
|
1424
|
-
|
1425
|
-
#
|
1426
|
-
# source://json//lib/json/common.rb#374
|
1427
|
-
def pretty_unparse(obj, opts = T.unsafe(nil)); end
|
1428
|
-
|
1429
|
-
# Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
|
1430
|
-
#
|
1431
|
-
# source://json//lib/json/common.rb#559
|
1432
|
-
def recurse_proc(result, &proc); end
|
1570
|
+
# source://json//lib/json/common.rb#948
|
1571
|
+
def pretty_unparse(*_arg0, **_arg1, &_arg2); end
|
1433
1572
|
|
1434
|
-
# source://json//lib/json/common.rb#
|
1435
|
-
def restore(
|
1573
|
+
# source://json//lib/json/common.rb#958
|
1574
|
+
def restore(*_arg0, **_arg1, &_arg2); end
|
1436
1575
|
|
1437
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
1438
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
1439
|
-
# JSON.state # => JSON::Ext::Generator::State
|
1576
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
1440
1577
|
#
|
1441
|
-
# source://json//lib/json/common.rb#
|
1578
|
+
# source://json//lib/json/common.rb#185
|
1442
1579
|
def state; end
|
1443
1580
|
|
1444
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
1445
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
1446
|
-
# JSON.state # => JSON::Ext::Generator::State
|
1581
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
1447
1582
|
#
|
1448
|
-
# source://json//lib/json/common.rb#
|
1583
|
+
# source://json//lib/json/common.rb#185
|
1449
1584
|
def state=(_arg0); end
|
1450
1585
|
|
1451
1586
|
# :stopdoc:
|
1452
|
-
#
|
1453
|
-
#
|
1587
|
+
# All these were meant to be deprecated circa 2009, but were just set as undocumented
|
1588
|
+
# so usage still exist in the wild.
|
1454
1589
|
#
|
1455
|
-
# source://json//lib/json/common.rb#
|
1456
|
-
def unparse(
|
1590
|
+
# source://json//lib/json/common.rb#928
|
1591
|
+
def unparse(*_arg0, **_arg1, &_arg2); end
|
1592
|
+
|
1593
|
+
# :call-seq:
|
1594
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
1595
|
+
#
|
1596
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
1597
|
+
#
|
1598
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
1599
|
+
# like from your own database server or clients under your control, it could
|
1600
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
1601
|
+
#
|
1602
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
1603
|
+
# - If +source+ responds to instance method +to_str+,
|
1604
|
+
# <tt>source.to_str</tt> becomes the source.
|
1605
|
+
# - If +source+ responds to instance method +to_io+,
|
1606
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
1607
|
+
# - If +source+ responds to instance method +read+,
|
1608
|
+
# <tt>source.read</tt> becomes the source.
|
1609
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
1610
|
+
# - Option +allow_blank+ specifies a truthy value.
|
1611
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
1612
|
+
# - Otherwise, +source+ remains the source.
|
1613
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1614
|
+
# It will be called recursively with each result (depth-first order).
|
1615
|
+
# See details below.
|
1616
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1617
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1618
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
1619
|
+
#
|
1620
|
+
# ---
|
1621
|
+
#
|
1622
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
1623
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
1624
|
+
#
|
1625
|
+
# Source for following examples:
|
1626
|
+
# source = <<~JSON
|
1627
|
+
# {
|
1628
|
+
# "name": "Dave",
|
1629
|
+
# "age" :40,
|
1630
|
+
# "hats": [
|
1631
|
+
# "Cattleman's",
|
1632
|
+
# "Panama",
|
1633
|
+
# "Tophat"
|
1634
|
+
# ]
|
1635
|
+
# }
|
1636
|
+
# JSON
|
1637
|
+
#
|
1638
|
+
# Load a \String:
|
1639
|
+
# ruby = JSON.unsafe_load(source)
|
1640
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1641
|
+
#
|
1642
|
+
# Load an \IO object:
|
1643
|
+
# require 'stringio'
|
1644
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
1645
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1646
|
+
#
|
1647
|
+
# Load a \File object:
|
1648
|
+
# path = 't.json'
|
1649
|
+
# File.write(path, source)
|
1650
|
+
# File.open(path) do |file|
|
1651
|
+
# JSON.unsafe_load(file)
|
1652
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1653
|
+
#
|
1654
|
+
# ---
|
1655
|
+
#
|
1656
|
+
# When +proc+ is given:
|
1657
|
+
# - Modifies +source+ as above.
|
1658
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
1659
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
1660
|
+
# - Returns the final result.
|
1661
|
+
#
|
1662
|
+
# Example:
|
1663
|
+
# require 'json'
|
1664
|
+
#
|
1665
|
+
# # Some classes for the example.
|
1666
|
+
# class Base
|
1667
|
+
# def initialize(attributes)
|
1668
|
+
# @attributes = attributes
|
1669
|
+
# end
|
1670
|
+
# end
|
1671
|
+
# class User < Base; end
|
1672
|
+
# class Account < Base; end
|
1673
|
+
# class Admin < Base; end
|
1674
|
+
# # The JSON source.
|
1675
|
+
# json = <<-EOF
|
1676
|
+
# {
|
1677
|
+
# "users": [
|
1678
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
1679
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
1680
|
+
# ],
|
1681
|
+
# "accounts": [
|
1682
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
1683
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
1684
|
+
# ],
|
1685
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
1686
|
+
# }
|
1687
|
+
# EOF
|
1688
|
+
# # Deserializer method.
|
1689
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
1690
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
1691
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
1692
|
+
# end
|
1693
|
+
# # Call to JSON.unsafe_load
|
1694
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
1695
|
+
# case obj
|
1696
|
+
# when Hash
|
1697
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
1698
|
+
# when Array
|
1699
|
+
# obj.map! {|v| deserialize_obj v }
|
1700
|
+
# end
|
1701
|
+
# })
|
1702
|
+
# pp ruby
|
1703
|
+
# Output:
|
1704
|
+
# {"users"=>
|
1705
|
+
# [#<User:0x00000000064c4c98
|
1706
|
+
# @attributes=
|
1707
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
1708
|
+
# #<User:0x00000000064c4bd0
|
1709
|
+
# @attributes=
|
1710
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
1711
|
+
# "accounts"=>
|
1712
|
+
# [{"account"=>
|
1713
|
+
# #<Account:0x00000000064c4928
|
1714
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
1715
|
+
# {"account"=>
|
1716
|
+
# #<Account:0x00000000064c4680
|
1717
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
1718
|
+
# "admins"=>
|
1719
|
+
# #<Admin:0x00000000064c41f8
|
1720
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1721
|
+
#
|
1722
|
+
# source://json//lib/json/common.rb#667
|
1723
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1724
|
+
|
1725
|
+
# source://json//lib/json/common.rb#192
|
1726
|
+
def unsafe_load_default_options; end
|
1727
|
+
|
1728
|
+
# source://json//lib/json/common.rb#192
|
1729
|
+
def unsafe_load_default_options=(val); end
|
1457
1730
|
|
1458
1731
|
private
|
1459
1732
|
|
1460
|
-
# source://json//lib/json/common.rb#
|
1461
|
-
def
|
1733
|
+
# source://json//lib/json/common.rb#971
|
1734
|
+
def const_missing(const_name); end
|
1735
|
+
|
1736
|
+
# source://json//lib/json/common.rb#189
|
1737
|
+
def deprecated_singleton_attr_accessor(*attrs); end
|
1738
|
+
end
|
1739
|
+
end
|
1740
|
+
|
1741
|
+
# JSON::Coder holds a parser and generator configuration.
|
1742
|
+
#
|
1743
|
+
# module MyApp
|
1744
|
+
# JSONC_CODER = JSON::Coder.new(
|
1745
|
+
# allow_trailing_comma: true
|
1746
|
+
# )
|
1747
|
+
# end
|
1748
|
+
#
|
1749
|
+
# MyApp::JSONC_CODER.load(document)
|
1750
|
+
#
|
1751
|
+
# source://json//lib/json/common.rb#997
|
1752
|
+
class JSON::Coder
|
1753
|
+
# :call-seq:
|
1754
|
+
# JSON.new(options = nil, &block)
|
1755
|
+
#
|
1756
|
+
# Argument +options+, if given, contains a \Hash of options for both parsing and generating.
|
1757
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options].
|
1758
|
+
#
|
1759
|
+
# For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
|
1760
|
+
# encoutered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
|
1761
|
+
# \JSON counterpart:
|
1762
|
+
#
|
1763
|
+
# module MyApp
|
1764
|
+
# API_JSON_CODER = JSON::Coder.new do |object|
|
1765
|
+
# case object
|
1766
|
+
# when Time
|
1767
|
+
# object.iso8601(3)
|
1768
|
+
# else
|
1769
|
+
# object # Unknown type, will raise
|
1770
|
+
# end
|
1771
|
+
# end
|
1772
|
+
# end
|
1773
|
+
#
|
1774
|
+
# puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
|
1775
|
+
#
|
1776
|
+
# @return [Coder] a new instance of Coder
|
1777
|
+
#
|
1778
|
+
# source://json//lib/json/common.rb#1021
|
1779
|
+
def initialize(options = T.unsafe(nil), &as_json); end
|
1780
|
+
|
1781
|
+
# call-seq:
|
1782
|
+
# dump(object) -> String
|
1783
|
+
# dump(object, io) -> io
|
1784
|
+
#
|
1785
|
+
# Serialize the given object into a \JSON document.
|
1786
|
+
#
|
1787
|
+
# source://json//lib/json/common.rb#1039
|
1788
|
+
def dump(object, io = T.unsafe(nil)); end
|
1789
|
+
|
1790
|
+
# call-seq:
|
1791
|
+
# dump(object) -> String
|
1792
|
+
# dump(object, io) -> io
|
1793
|
+
#
|
1794
|
+
# Serialize the given object into a \JSON document.
|
1795
|
+
#
|
1796
|
+
# source://json//lib/json/common.rb#1042
|
1797
|
+
def generate(object, io = T.unsafe(nil)); end
|
1798
|
+
|
1799
|
+
# call-seq:
|
1800
|
+
# load(string) -> Object
|
1801
|
+
#
|
1802
|
+
# Parse the given \JSON document and return an equivalent Ruby object.
|
1803
|
+
#
|
1804
|
+
# source://json//lib/json/common.rb#1048
|
1805
|
+
def load(source); end
|
1806
|
+
|
1807
|
+
# call-seq:
|
1808
|
+
# load(path) -> Object
|
1809
|
+
#
|
1810
|
+
# Parse the given \JSON document and return an equivalent Ruby object.
|
1811
|
+
#
|
1812
|
+
# source://json//lib/json/common.rb#1057
|
1813
|
+
def load_file(path); end
|
1814
|
+
|
1815
|
+
# call-seq:
|
1816
|
+
# load(string) -> Object
|
1817
|
+
#
|
1818
|
+
# Parse the given \JSON document and return an equivalent Ruby object.
|
1819
|
+
#
|
1820
|
+
# source://json//lib/json/common.rb#1051
|
1821
|
+
def parse(source); end
|
1822
|
+
end
|
1823
|
+
|
1824
|
+
module JSON::Ext::Generator::GeneratorMethods::Array
|
1825
|
+
# source://json//lib/json/ext.rb#39
|
1826
|
+
def to_json(*_arg0); end
|
1827
|
+
end
|
1828
|
+
|
1829
|
+
module JSON::Ext::Generator::GeneratorMethods::FalseClass
|
1830
|
+
# source://json//lib/json/ext.rb#39
|
1831
|
+
def to_json(*_arg0); end
|
1832
|
+
end
|
1833
|
+
|
1834
|
+
module JSON::Ext::Generator::GeneratorMethods::Float
|
1835
|
+
# source://json//lib/json/ext.rb#39
|
1836
|
+
def to_json(*_arg0); end
|
1837
|
+
end
|
1838
|
+
|
1839
|
+
module JSON::Ext::Generator::GeneratorMethods::Hash
|
1840
|
+
# source://json//lib/json/ext.rb#39
|
1841
|
+
def to_json(*_arg0); end
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
module JSON::Ext::Generator::GeneratorMethods::Integer
|
1845
|
+
# source://json//lib/json/ext.rb#39
|
1846
|
+
def to_json(*_arg0); end
|
1847
|
+
end
|
1848
|
+
|
1849
|
+
module JSON::Ext::Generator::GeneratorMethods::NilClass
|
1850
|
+
# source://json//lib/json/ext.rb#39
|
1851
|
+
def to_json(*_arg0); end
|
1852
|
+
end
|
1853
|
+
|
1854
|
+
module JSON::Ext::Generator::GeneratorMethods::Object
|
1855
|
+
# source://json//lib/json/ext.rb#39
|
1856
|
+
def to_json(*_arg0); end
|
1857
|
+
end
|
1858
|
+
|
1859
|
+
module JSON::Ext::Generator::GeneratorMethods::String
|
1860
|
+
mixes_in_class_methods ::JSON::Ext::Generator::GeneratorMethods::String::Extend
|
1861
|
+
|
1862
|
+
# source://json//lib/json/ext.rb#39
|
1863
|
+
def to_json(*_arg0); end
|
1864
|
+
|
1865
|
+
# source://json//lib/json/ext.rb#39
|
1866
|
+
def to_json_raw(*_arg0); end
|
1867
|
+
|
1868
|
+
# source://json//lib/json/ext.rb#39
|
1869
|
+
def to_json_raw_object; end
|
1870
|
+
|
1871
|
+
class << self
|
1872
|
+
# source://json//lib/json/ext.rb#39
|
1873
|
+
def included(_arg0); end
|
1874
|
+
end
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
module JSON::Ext::Generator::GeneratorMethods::String::Extend
|
1878
|
+
# source://json//lib/json/ext.rb#39
|
1879
|
+
def json_create(_arg0); end
|
1880
|
+
end
|
1881
|
+
|
1882
|
+
module JSON::Ext::Generator::GeneratorMethods::TrueClass
|
1883
|
+
# source://json//lib/json/ext.rb#39
|
1884
|
+
def to_json(*_arg0); end
|
1885
|
+
end
|
1886
|
+
|
1887
|
+
# source://json//lib/json/ext/generator/state.rb#6
|
1888
|
+
class JSON::Ext::Generator::State
|
1889
|
+
# call-seq: new(opts = {})
|
1890
|
+
#
|
1891
|
+
# Instantiates a new State object, configured by _opts_.
|
1892
|
+
#
|
1893
|
+
# _opts_ can have the following keys:
|
1894
|
+
#
|
1895
|
+
# * *indent*: a string used to indent levels (default: ''),
|
1896
|
+
# * *space*: a string that is put after, a : or , delimiter (default: ''),
|
1897
|
+
# * *space_before*: a string that is put before a : pair delimiter (default: ''),
|
1898
|
+
# * *object_nl*: a string that is put at the end of a JSON object (default: ''),
|
1899
|
+
# * *array_nl*: a string that is put at the end of a JSON array (default: ''),
|
1900
|
+
# * *allow_nan*: true if NaN, Infinity, and -Infinity should be
|
1901
|
+
# generated, otherwise an exception is thrown, if these values are
|
1902
|
+
# encountered. This options defaults to false.
|
1903
|
+
# * *ascii_only*: true if only ASCII characters should be generated. This
|
1904
|
+
# option defaults to false.
|
1905
|
+
# * *buffer_initial_length*: sets the initial length of the generator's
|
1906
|
+
# internal buffer.
|
1907
|
+
#
|
1908
|
+
# @return [State] a new instance of State
|
1909
|
+
#
|
1910
|
+
# source://json//lib/json/ext.rb#39
|
1911
|
+
def initialize(opts = T.unsafe(nil)); end
|
1912
|
+
|
1913
|
+
# call-seq: [](name)
|
1914
|
+
#
|
1915
|
+
# Returns the value returned by method +name+.
|
1916
|
+
#
|
1917
|
+
# source://json//lib/json/ext/generator/state.rb#84
|
1918
|
+
def [](name); end
|
1919
|
+
|
1920
|
+
# call-seq: []=(name, value)
|
1921
|
+
#
|
1922
|
+
# Sets the attribute name to value.
|
1923
|
+
#
|
1924
|
+
# source://json//lib/json/ext/generator/state.rb#96
|
1925
|
+
def []=(name, value); end
|
1926
|
+
|
1927
|
+
# source://json//lib/json/ext.rb#39
|
1928
|
+
def allow_nan=(_arg0); end
|
1929
|
+
|
1930
|
+
# source://json//lib/json/ext.rb#39
|
1931
|
+
def allow_nan?; end
|
1932
|
+
|
1933
|
+
# source://json//lib/json/ext.rb#39
|
1934
|
+
def array_nl; end
|
1935
|
+
|
1936
|
+
# source://json//lib/json/ext.rb#39
|
1937
|
+
def array_nl=(_arg0); end
|
1938
|
+
|
1939
|
+
# source://json//lib/json/ext.rb#39
|
1940
|
+
def as_json; end
|
1941
|
+
|
1942
|
+
# source://json//lib/json/ext.rb#39
|
1943
|
+
def as_json=(_arg0); end
|
1944
|
+
|
1945
|
+
# source://json//lib/json/ext.rb#39
|
1946
|
+
def ascii_only=(_arg0); end
|
1947
|
+
|
1948
|
+
# source://json//lib/json/ext.rb#39
|
1949
|
+
def ascii_only?; end
|
1950
|
+
|
1951
|
+
# source://json//lib/json/ext.rb#39
|
1952
|
+
def buffer_initial_length; end
|
1953
|
+
|
1954
|
+
# source://json//lib/json/ext.rb#39
|
1955
|
+
def buffer_initial_length=(_arg0); end
|
1956
|
+
|
1957
|
+
# source://json//lib/json/ext.rb#39
|
1958
|
+
def check_circular?; end
|
1959
|
+
|
1960
|
+
# call-seq: configure(opts)
|
1961
|
+
#
|
1962
|
+
# Configure this State instance with the Hash _opts_, and return
|
1963
|
+
# itself.
|
1964
|
+
#
|
1965
|
+
# source://json//lib/json/ext/generator/state.rb#35
|
1966
|
+
def configure(opts); end
|
1967
|
+
|
1968
|
+
# source://json//lib/json/ext.rb#39
|
1969
|
+
def depth; end
|
1970
|
+
|
1971
|
+
# source://json//lib/json/ext.rb#39
|
1972
|
+
def depth=(_arg0); end
|
1973
|
+
|
1974
|
+
# source://json//lib/json/ext.rb#39
|
1975
|
+
def escape_slash; end
|
1976
|
+
|
1977
|
+
# source://json//lib/json/ext.rb#39
|
1978
|
+
def escape_slash=(_arg0); end
|
1979
|
+
|
1980
|
+
# source://json//lib/json/ext.rb#39
|
1981
|
+
def escape_slash?; end
|
1982
|
+
|
1983
|
+
# source://json//lib/json/ext.rb#39
|
1984
|
+
def generate(*_arg0); end
|
1985
|
+
|
1986
|
+
# source://json//lib/json/ext.rb#39
|
1987
|
+
def generate_new(*_arg0); end
|
1988
|
+
|
1989
|
+
# source://json//lib/json/ext.rb#39
|
1990
|
+
def indent; end
|
1991
|
+
|
1992
|
+
# source://json//lib/json/ext.rb#39
|
1993
|
+
def indent=(_arg0); end
|
1994
|
+
|
1995
|
+
# source://json//lib/json/ext.rb#39
|
1996
|
+
def max_nesting; end
|
1997
|
+
|
1998
|
+
# source://json//lib/json/ext.rb#39
|
1999
|
+
def max_nesting=(_arg0); end
|
2000
|
+
|
2001
|
+
# call-seq: configure(opts)
|
2002
|
+
#
|
2003
|
+
# Configure this State instance with the Hash _opts_, and return
|
2004
|
+
# itself.
|
2005
|
+
#
|
2006
|
+
# source://json//lib/json/ext/generator/state.rb#48
|
2007
|
+
def merge(opts); end
|
2008
|
+
|
2009
|
+
# source://json//lib/json/ext.rb#39
|
2010
|
+
def object_nl; end
|
2011
|
+
|
2012
|
+
# source://json//lib/json/ext.rb#39
|
2013
|
+
def object_nl=(_arg0); end
|
2014
|
+
|
2015
|
+
# source://json//lib/json/ext.rb#39
|
2016
|
+
def script_safe; end
|
2017
|
+
|
2018
|
+
# source://json//lib/json/ext.rb#39
|
2019
|
+
def script_safe=(_arg0); end
|
2020
|
+
|
2021
|
+
# source://json//lib/json/ext.rb#39
|
2022
|
+
def script_safe?; end
|
2023
|
+
|
2024
|
+
# source://json//lib/json/ext.rb#39
|
2025
|
+
def space; end
|
2026
|
+
|
2027
|
+
# source://json//lib/json/ext.rb#39
|
2028
|
+
def space=(_arg0); end
|
2029
|
+
|
2030
|
+
# source://json//lib/json/ext.rb#39
|
2031
|
+
def space_before; end
|
2032
|
+
|
2033
|
+
# source://json//lib/json/ext.rb#39
|
2034
|
+
def space_before=(_arg0); end
|
2035
|
+
|
2036
|
+
# source://json//lib/json/ext.rb#39
|
2037
|
+
def strict; end
|
2038
|
+
|
2039
|
+
# source://json//lib/json/ext.rb#39
|
2040
|
+
def strict=(_arg0); end
|
2041
|
+
|
2042
|
+
# source://json//lib/json/ext.rb#39
|
2043
|
+
def strict?; end
|
2044
|
+
|
2045
|
+
# call-seq: to_h
|
2046
|
+
#
|
2047
|
+
# Returns the configuration instance variables as a hash, that can be
|
2048
|
+
# passed to the configure method.
|
2049
|
+
#
|
2050
|
+
# source://json//lib/json/ext/generator/state.rb#54
|
2051
|
+
def to_h; end
|
2052
|
+
|
2053
|
+
# call-seq: to_h
|
2054
|
+
#
|
2055
|
+
# Returns the configuration instance variables as a hash, that can be
|
2056
|
+
# passed to the configure method.
|
2057
|
+
#
|
2058
|
+
# source://json//lib/json/ext/generator/state.rb#79
|
2059
|
+
def to_hash; end
|
2060
|
+
|
2061
|
+
private
|
2062
|
+
|
2063
|
+
# source://json//lib/json/ext.rb#39
|
2064
|
+
def _configure(_arg0); end
|
2065
|
+
|
2066
|
+
# source://json//lib/json/ext.rb#39
|
2067
|
+
def initialize_copy(_arg0); end
|
2068
|
+
|
2069
|
+
class << self
|
2070
|
+
# source://json//lib/json/ext.rb#39
|
2071
|
+
def from_state(_arg0); end
|
2072
|
+
|
2073
|
+
# source://json//lib/json/ext.rb#39
|
2074
|
+
def generate(_arg0, _arg1, _arg2); end
|
2075
|
+
end
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
# source://json//lib/json/ext.rb#9
|
2079
|
+
class JSON::Ext::Parser
|
2080
|
+
# @return [Parser] a new instance of Parser
|
2081
|
+
#
|
2082
|
+
# source://json//lib/json/ext.rb#17
|
2083
|
+
def initialize(source, opts = T.unsafe(nil)); end
|
2084
|
+
|
2085
|
+
# source://json//lib/json/ext.rb#26
|
2086
|
+
def parse; end
|
2087
|
+
|
2088
|
+
# source://json//lib/json/ext.rb#22
|
2089
|
+
def source; end
|
2090
|
+
|
2091
|
+
class << self
|
2092
|
+
# Allow redefinition by extensions
|
2093
|
+
# Allow redefinition by extensions
|
2094
|
+
#
|
2095
|
+
# source://json//lib/json/ext.rb#11
|
2096
|
+
def parse(_arg0, _arg1); end
|
1462
2097
|
end
|
1463
2098
|
end
|
1464
2099
|
|
1465
|
-
# source://json//lib/json/
|
1466
|
-
JSON::
|
2100
|
+
# source://json//lib/json/ext.rb#32
|
2101
|
+
JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
|
2102
|
+
|
2103
|
+
class JSON::Ext::ParserConfig
|
2104
|
+
# source://json//lib/json/ext.rb#31
|
2105
|
+
def initialize(_arg0); end
|
2106
|
+
|
2107
|
+
# source://json//lib/json/ext.rb#31
|
2108
|
+
def parse(_arg0); end
|
2109
|
+
end
|
2110
|
+
|
2111
|
+
# Fragment of JSON document that is to be included as is:
|
2112
|
+
# fragment = JSON::Fragment.new("[1, 2, 3]")
|
2113
|
+
# JSON.generate({ count: 3, items: fragments })
|
2114
|
+
#
|
2115
|
+
# This allows to easily assemble multiple JSON fragments that have
|
2116
|
+
# been persisted somewhere without having to parse them nor resorting
|
2117
|
+
# to string interpolation.
|
2118
|
+
#
|
2119
|
+
# Note: no validation is performed on the provided string. It is the
|
2120
|
+
# responsibility of the caller to ensure the string contains valid JSON.
|
2121
|
+
#
|
2122
|
+
# source://json//lib/json/common.rb#273
|
2123
|
+
class JSON::Fragment < ::Struct
|
2124
|
+
# @return [Fragment] a new instance of Fragment
|
2125
|
+
#
|
2126
|
+
# source://json//lib/json/common.rb#274
|
2127
|
+
def initialize(json); end
|
2128
|
+
|
2129
|
+
# Returns the value of attribute json
|
2130
|
+
#
|
2131
|
+
# @return [Object] the current value of json
|
2132
|
+
#
|
2133
|
+
# source://json//lib/json/common.rb#273
|
2134
|
+
def json; end
|
2135
|
+
|
2136
|
+
# Sets the attribute json
|
2137
|
+
#
|
2138
|
+
# @param value [Object] the value to set the attribute json to.
|
2139
|
+
# @return [Object] the newly set value
|
2140
|
+
#
|
2141
|
+
# source://json//lib/json/common.rb#273
|
2142
|
+
def json=(_); end
|
1467
2143
|
|
1468
|
-
# source://json//lib/json/common.rb#
|
1469
|
-
|
2144
|
+
# source://json//lib/json/common.rb#282
|
2145
|
+
def to_json(state = T.unsafe(nil), *_arg1); end
|
2146
|
+
|
2147
|
+
class << self
|
2148
|
+
# source://json//lib/json/common.rb#273
|
2149
|
+
def [](*_arg0); end
|
2150
|
+
|
2151
|
+
# source://json//lib/json/common.rb#273
|
2152
|
+
def inspect; end
|
2153
|
+
|
2154
|
+
# source://json//lib/json/common.rb#273
|
2155
|
+
def keyword_init?; end
|
2156
|
+
|
2157
|
+
# source://json//lib/json/common.rb#273
|
2158
|
+
def members; end
|
2159
|
+
|
2160
|
+
# source://json//lib/json/common.rb#273
|
2161
|
+
def new(*_arg0); end
|
2162
|
+
end
|
2163
|
+
end
|
2164
|
+
|
2165
|
+
# This exception is raised if a generator or unparser error occurs.
|
2166
|
+
#
|
2167
|
+
# source://json//lib/json/common.rb#243
|
2168
|
+
class JSON::GeneratorError < ::JSON::JSONError
|
2169
|
+
# @return [GeneratorError] a new instance of GeneratorError
|
2170
|
+
#
|
2171
|
+
# source://json//lib/json/common.rb#246
|
2172
|
+
def initialize(message, invalid_object = T.unsafe(nil)); end
|
2173
|
+
|
2174
|
+
# source://json//lib/json/common.rb#251
|
2175
|
+
def detailed_message(*_arg0, **_arg1, &_arg2); end
|
2176
|
+
|
2177
|
+
# Returns the value of attribute invalid_object.
|
2178
|
+
#
|
2179
|
+
# source://json//lib/json/common.rb#244
|
2180
|
+
def invalid_object; end
|
2181
|
+
end
|
1470
2182
|
|
1471
2183
|
# source://json//lib/json/generic_object.rb#9
|
1472
2184
|
class JSON::GenericObject < ::OpenStruct
|
@@ -1483,6 +2195,9 @@ class JSON::GenericObject < ::OpenStruct
|
|
1483
2195
|
def |(other); end
|
1484
2196
|
|
1485
2197
|
class << self
|
2198
|
+
# source://json//lib/json/generic_object.rb#11
|
2199
|
+
def [](*_arg0); end
|
2200
|
+
|
1486
2201
|
# source://json//lib/json/generic_object.rb#45
|
1487
2202
|
def dump(obj, *args); end
|
1488
2203
|
|
@@ -1509,31 +2224,58 @@ class JSON::GenericObject < ::OpenStruct
|
|
1509
2224
|
end
|
1510
2225
|
end
|
1511
2226
|
|
1512
|
-
#
|
2227
|
+
# source://json//lib/json/common.rb#342
|
2228
|
+
JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
|
2229
|
+
|
2230
|
+
# source://json//lib/json/common.rb#455
|
2231
|
+
JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
|
2232
|
+
|
2233
|
+
# source://json//lib/json/common.rb#147
|
2234
|
+
JSON::Parser = JSON::Ext::Parser
|
2235
|
+
|
2236
|
+
# This exception is raised if a parser error occurs.
|
1513
2237
|
#
|
1514
|
-
# source://json//lib/json/common.rb#
|
1515
|
-
class JSON::
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
end
|
2238
|
+
# source://json//lib/json/common.rb#234
|
2239
|
+
class JSON::ParserError < ::JSON::JSONError
|
2240
|
+
# Returns the value of attribute column.
|
2241
|
+
#
|
2242
|
+
# source://json//lib/json/common.rb#235
|
2243
|
+
def column; end
|
2244
|
+
|
2245
|
+
# Returns the value of attribute line.
|
2246
|
+
#
|
2247
|
+
# source://json//lib/json/common.rb#235
|
2248
|
+
def line; end
|
1520
2249
|
end
|
1521
2250
|
|
1522
|
-
# source://json//lib/json/common.rb#
|
1523
|
-
JSON::
|
2251
|
+
# source://json//lib/json/common.rb#8
|
2252
|
+
module JSON::ParserOptions
|
2253
|
+
class << self
|
2254
|
+
# source://json//lib/json/common.rb#10
|
2255
|
+
def prepare(opts); end
|
1524
2256
|
|
1525
|
-
|
1526
|
-
JSON::Parser = JSON::Ext::Parser
|
2257
|
+
private
|
1527
2258
|
|
1528
|
-
# source://json//lib/json/common.rb#
|
1529
|
-
|
2259
|
+
# source://json//lib/json/common.rb#40
|
2260
|
+
def array_class_proc(array_class, on_load); end
|
1530
2261
|
|
1531
|
-
#
|
1532
|
-
#
|
1533
|
-
# source://json//lib/json/common.rb#
|
1534
|
-
|
2262
|
+
# TODO: extract :create_additions support to another gem for version 3.0
|
2263
|
+
#
|
2264
|
+
# source://json//lib/json/common.rb#52
|
2265
|
+
def create_additions_proc(opts); end
|
1535
2266
|
|
1536
|
-
# source://json//lib/json/common.rb#
|
2267
|
+
# source://json//lib/json/common.rb#90
|
2268
|
+
def create_additions_warning; end
|
2269
|
+
|
2270
|
+
# source://json//lib/json/common.rb#29
|
2271
|
+
def object_class_proc(object_class, on_load); end
|
2272
|
+
end
|
2273
|
+
end
|
2274
|
+
|
2275
|
+
# source://json//lib/json/common.rb#176
|
2276
|
+
JSON::State = JSON::Ext::Generator::State
|
2277
|
+
|
2278
|
+
# source://json//lib/json/common.rb#1063
|
1537
2279
|
module Kernel
|
1538
2280
|
private
|
1539
2281
|
|
@@ -1544,18 +2286,38 @@ module Kernel
|
|
1544
2286
|
# The _opts_ argument is passed through to generate/parse respectively. See
|
1545
2287
|
# generate and parse for their documentation.
|
1546
2288
|
#
|
1547
|
-
# source://json//lib/json/common.rb#
|
1548
|
-
def JSON(object,
|
2289
|
+
# source://json//lib/json/common.rb#1102
|
2290
|
+
def JSON(object, opts = T.unsafe(nil)); end
|
1549
2291
|
|
1550
2292
|
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
1551
2293
|
# one line.
|
1552
2294
|
#
|
1553
|
-
# source://json//lib/json/common.rb#
|
2295
|
+
# source://json//lib/json/common.rb#1068
|
1554
2296
|
def j(*objs); end
|
1555
2297
|
|
1556
2298
|
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
1557
2299
|
# indentation and over many lines.
|
1558
2300
|
#
|
1559
|
-
# source://json//lib/json/common.rb#
|
2301
|
+
# source://json//lib/json/common.rb#1083
|
1560
2302
|
def jj(*objs); end
|
1561
2303
|
end
|
2304
|
+
|
2305
|
+
class NilClass
|
2306
|
+
include ::JSON::Ext::Generator::GeneratorMethods::NilClass
|
2307
|
+
end
|
2308
|
+
|
2309
|
+
class Object < ::BasicObject
|
2310
|
+
include ::Kernel
|
2311
|
+
include ::PP::ObjectMixin
|
2312
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Object
|
2313
|
+
end
|
2314
|
+
|
2315
|
+
class String
|
2316
|
+
include ::Comparable
|
2317
|
+
include ::JSON::Ext::Generator::GeneratorMethods::String
|
2318
|
+
extend ::JSON::Ext::Generator::GeneratorMethods::String::Extend
|
2319
|
+
end
|
2320
|
+
|
2321
|
+
class TrueClass
|
2322
|
+
include ::JSON::Ext::Generator::GeneratorMethods::TrueClass
|
2323
|
+
end
|