sorbet-result 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile.lock +73 -51
  5. data/README.md +1 -1
  6. data/lib/typed/no_payload_on_failure_error.rb +8 -3
  7. data/lib/typed/result.rb +1 -1
  8. data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +3 -3
  9. data/sorbet/rbi/gems/benchmark@0.4.1.rbi +619 -0
  10. data/sorbet/rbi/gems/cgi@0.5.0.rbi +2961 -0
  11. data/sorbet/rbi/gems/date@3.4.1.rbi +75 -0
  12. data/sorbet/rbi/gems/erb@4.0.4.rbi +910 -0
  13. data/sorbet/rbi/gems/{erubi@1.13.0.rbi → erubi@1.13.1.rbi} +14 -9
  14. data/sorbet/rbi/gems/{json@2.7.5.rbi → json@2.12.2.rbi} +654 -232
  15. data/sorbet/rbi/gems/{language_server-protocol@3.17.0.3.rbi → language_server-protocol@3.17.0.5.rbi} +11 -5
  16. data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
  17. data/sorbet/rbi/gems/{minitest@5.25.1.rbi → minitest@5.25.5.rbi} +227 -220
  18. data/sorbet/rbi/gems/{parser@3.3.5.1.rbi → parser@3.3.8.0.rbi} +215 -199
  19. data/sorbet/rbi/gems/pp@0.6.2.rbi +368 -0
  20. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +477 -0
  21. data/sorbet/rbi/gems/{prism@1.2.0.rbi → prism@1.4.0.rbi} +6569 -3922
  22. data/sorbet/rbi/gems/{psych@5.1.2.rbi → psych@5.2.6.rbi} +973 -236
  23. data/sorbet/rbi/gems/{rake@13.2.1.rbi → rake@13.3.0.rbi} +15 -12
  24. data/sorbet/rbi/gems/{rbi@0.2.1.rbi → rbi@0.3.6.rbi} +3340 -982
  25. data/sorbet/rbi/gems/rbs@3.9.4.rbi +6976 -0
  26. data/sorbet/rbi/gems/{regexp_parser@2.9.2.rbi → regexp_parser@2.10.0.rbi} +193 -170
  27. data/sorbet/rbi/gems/{rubocop-ast@1.33.1.rbi → rubocop-ast@1.45.1.rbi} +1069 -826
  28. data/sorbet/rbi/gems/{rubocop@1.66.1.rbi → rubocop@1.75.8.rbi} +7880 -4054
  29. data/sorbet/rbi/gems/{spoom@1.5.0.rbi → spoom@1.6.1.rbi} +3315 -973
  30. data/sorbet/rbi/gems/{standard@1.41.1.rbi → standard@1.50.0.rbi} +68 -59
  31. data/sorbet/rbi/gems/{tapioca@0.16.3.rbi → tapioca@0.16.11.rbi} +273 -248
  32. data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +132 -0
  33. data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
  34. metadata +41 -33
  35. data/.tool-versions +0 -1
  36. data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +0 -66
  37. /data/sorbet/rbi/gems/{io-console@0.7.2.rbi → io-console@0.8.0.rbi} +0 -0
  38. /data/sorbet/rbi/gems/{parallel@1.26.3.rbi → parallel@1.27.0.rbi} +0 -0
  39. /data/sorbet/rbi/gems/{reline@0.5.10.rbi → reline@0.6.1.rbi} +0 -0
  40. /data/sorbet/rbi/gems/{rubocop-performance@1.22.1.rbi → rubocop-performance@1.25.0.rbi} +0 -0
  41. /data/sorbet/rbi/gems/{rubocop-sorbet@0.7.8.rbi → rubocop-sorbet@0.9.0.rbi} +0 -0
  42. /data/sorbet/rbi/gems/{standard-performance@1.5.0.rbi → standard-performance@1.8.0.rbi} +0 -0
  43. /data/sorbet/rbi/gems/{standard-sorbet@0.0.2.rbi → standard-sorbet@0.0.3.rbi} +0 -0
  44. /data/sorbet/rbi/gems/{stringio@3.1.1.rbi → stringio@3.1.7.rbi} +0 -0
@@ -5,19 +5,26 @@
5
5
  # Please instead update this file by running `bin/tapioca gem json`.
6
6
 
7
7
 
8
- # Extends any Class to include _json_creatable?_ method.
9
- #
10
- # source://json//lib/json/common.rb#726
11
- class Class < ::Module
12
- # Returns true if this class can be used to create an instance
13
- # from a serialised JSON string. The class has to implement a class
14
- # method _json_create_ that expects a hash as first parameter. The hash
15
- # should include the required data.
16
- #
17
- # @return [Boolean]
18
- #
19
- # source://json//lib/json/common.rb#731
20
- def json_creatable?; end
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
21
28
  end
22
29
 
23
30
  # = JavaScript \Object Notation (\JSON)
@@ -396,13 +403,13 @@ end
396
403
  # json1 = JSON.generate(ruby)
397
404
  # ruby1 = JSON.parse(json1, create_additions: true)
398
405
  # # Make a nice display.
399
- # display = <<EOT
400
- # Generated JSON:
401
- # Without addition: #{json0} (#{json0.class})
402
- # With addition: #{json1} (#{json1.class})
403
- # Parsed JSON:
404
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
405
- # With addition: #{ruby1.inspect} (#{ruby1.class})
406
+ # display = <<~EOT
407
+ # Generated JSON:
408
+ # Without addition: #{json0} (#{json0.class})
409
+ # With addition: #{json1} (#{json1.class})
410
+ # Parsed JSON:
411
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
412
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
406
413
  # EOT
407
414
  # puts display
408
415
  #
@@ -580,13 +587,13 @@ end
580
587
  # json1 = JSON.generate(foo1)
581
588
  # obj1 = JSON.parse(json1, create_additions: true)
582
589
  # # Make a nice display.
583
- # display = <<EOT
584
- # Generated JSON:
585
- # Without custom addition: #{json0} (#{json0.class})
586
- # With custom addition: #{json1} (#{json1.class})
587
- # Parsed JSON:
588
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
589
- # With custom addition: #{obj1.inspect} (#{obj1.class})
590
+ # display = <<~EOT
591
+ # Generated JSON:
592
+ # Without custom addition: #{json0} (#{json0.class})
593
+ # With custom addition: #{json1} (#{json1.class})
594
+ # Parsed JSON:
595
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
596
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
590
597
  # EOT
591
598
  # puts display
592
599
  #
@@ -631,7 +638,7 @@ module JSON
631
638
  # Output:
632
639
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
633
640
  #
634
- # source://json//lib/json/common.rb#630
641
+ # source://json//lib/json/common.rb#892
635
642
  def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
636
643
 
637
644
  # :call-seq:
@@ -648,14 +655,11 @@ module JSON
648
655
  # # Raises SystemStackError (stack level too deep):
649
656
  # JSON.fast_generate(a)
650
657
  #
651
- # source://json//lib/json/common.rb#337
658
+ # source://json//lib/json/common.rb#445
652
659
  def fast_generate(obj, opts = T.unsafe(nil)); end
653
660
 
654
- # :stopdoc:
655
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
656
- #
657
- # source://json//lib/json/common.rb#337
658
- def fast_unparse(obj, opts = T.unsafe(nil)); end
661
+ # source://json//lib/json/common.rb#937
662
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
659
663
 
660
664
  # :call-seq:
661
665
  # JSON.generate(obj, opts = nil) -> new_string
@@ -693,7 +697,7 @@ module JSON
693
697
  # # Raises JSON::NestingError (nesting of 100 is too deep):
694
698
  # JSON.generate(a)
695
699
  #
696
- # source://json//lib/json/common.rb#308
700
+ # source://json//lib/json/common.rb#424
697
701
  def generate(obj, opts = T.unsafe(nil)); end
698
702
 
699
703
  # :call-seq:
@@ -701,6 +705,16 @@ module JSON
701
705
  #
702
706
  # Returns the Ruby objects created by parsing the given +source+.
703
707
  #
708
+ # BEWARE: This method is meant to serialise data from trusted user input,
709
+ # like from your own database server or clients under your control, it could
710
+ # be dangerous to allow untrusted users to pass JSON sources into it.
711
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
712
+ #
713
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
714
+ # non native type is deserialized, without `create_additions` being explicitly
715
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
716
+ # by default.
717
+ #
704
718
  # - Argument +source+ must be, or be convertible to, a \String:
705
719
  # - If +source+ responds to instance method +to_str+,
706
720
  # <tt>source.to_str</tt> becomes the source.
@@ -715,9 +729,6 @@ module JSON
715
729
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
716
730
  # It will be called recursively with each result (depth-first order).
717
731
  # See details below.
718
- # BEWARE: This method is meant to serialise data from trusted user input,
719
- # like from your own database server or clients under your control, it could
720
- # be dangerous to allow untrusted users to pass JSON sources into it.
721
732
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
722
733
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
723
734
  # The default options can be changed via method JSON.load_default_options=.
@@ -728,17 +739,17 @@ module JSON
728
739
  # <tt>parse(source, opts)</tt>; see #parse.
729
740
  #
730
741
  # Source for following examples:
731
- # source = <<-EOT
732
- # {
733
- # "name": "Dave",
734
- # "age" :40,
735
- # "hats": [
736
- # "Cattleman's",
737
- # "Panama",
738
- # "Tophat"
739
- # ]
740
- # }
741
- # EOT
742
+ # source = <<~JSON
743
+ # {
744
+ # "name": "Dave",
745
+ # "age" :40,
746
+ # "hats": [
747
+ # "Cattleman's",
748
+ # "Panama",
749
+ # "Tophat"
750
+ # ]
751
+ # }
752
+ # JSON
742
753
  #
743
754
  # Load a \String:
744
755
  # ruby = JSON.load(source)
@@ -824,7 +835,7 @@ module JSON
824
835
  # #<Admin:0x00000000064c41f8
825
836
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
826
837
  #
827
- # source://json//lib/json/common.rb#549
838
+ # source://json//lib/json/common.rb#826
828
839
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
829
840
 
830
841
  # :call-seq:
@@ -835,7 +846,7 @@ module JSON
835
846
  #
836
847
  # See method #parse.
837
848
  #
838
- # source://json//lib/json/common.rb#257
849
+ # source://json//lib/json/common.rb#373
839
850
  def load_file(filespec, opts = T.unsafe(nil)); end
840
851
 
841
852
  # :call-seq:
@@ -846,12 +857,9 @@ module JSON
846
857
  #
847
858
  # See method #parse!
848
859
  #
849
- # source://json//lib/json/common.rb#268
860
+ # source://json//lib/json/common.rb#384
850
861
  def load_file!(filespec, opts = T.unsafe(nil)); end
851
862
 
852
- # source://json//lib/json/common.rb#674
853
- def merge_dump_options(opts, strict: T.unsafe(nil)); end
854
-
855
863
  # :call-seq:
856
864
  # JSON.parse(source, opts) -> object
857
865
  #
@@ -880,17 +888,17 @@ module JSON
880
888
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
881
889
  #
882
890
  # Parses nested JSON objects:
883
- # source = <<-EOT
884
- # {
885
- # "name": "Dave",
886
- # "age" :40,
887
- # "hats": [
888
- # "Cattleman's",
889
- # "Panama",
890
- # "Tophat"
891
- # ]
892
- # }
893
- # EOT
891
+ # source = <<~JSON
892
+ # {
893
+ # "name": "Dave",
894
+ # "age" :40,
895
+ # "hats": [
896
+ # "Cattleman's",
897
+ # "Panama",
898
+ # "Tophat"
899
+ # ]
900
+ # }
901
+ # JSON
894
902
  # ruby = JSON.parse(source)
895
903
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
896
904
  #
@@ -900,7 +908,7 @@ module JSON
900
908
  # # Raises JSON::ParserError (783: unexpected token at ''):
901
909
  # JSON.parse('')
902
910
  #
903
- # source://json//lib/json/common.rb#218
911
+ # source://json//lib/json/common.rb#336
904
912
  def parse(source, opts = T.unsafe(nil)); end
905
913
 
906
914
  # :call-seq:
@@ -915,7 +923,7 @@ module JSON
915
923
  # which disables checking for nesting depth.
916
924
  # - Option +allow_nan+, if not provided, defaults to +true+.
917
925
  #
918
- # source://json//lib/json/common.rb#242
926
+ # source://json//lib/json/common.rb#358
919
927
  def parse!(source, opts = T.unsafe(nil)); end
920
928
 
921
929
  # :call-seq:
@@ -948,29 +956,153 @@ module JSON
948
956
  # }
949
957
  # }
950
958
  #
951
- # source://json//lib/json/common.rb#382
959
+ # source://json//lib/json/common.rb#492
952
960
  def pretty_generate(obj, opts = T.unsafe(nil)); end
953
961
 
962
+ # source://json//lib/json/common.rb#947
963
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
964
+
965
+ # source://json//lib/json/common.rb#957
966
+ def restore(*_arg0, **_arg1, &_arg2); end
967
+
954
968
  # :stopdoc:
955
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
969
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
970
+ # so usage still exist in the wild.
956
971
  #
957
- # source://json//lib/json/common.rb#382
958
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
972
+ # source://json//lib/json/common.rb#927
973
+ def unparse(*_arg0, **_arg1, &_arg2); end
959
974
 
960
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
975
+ # :call-seq:
976
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
961
977
  #
962
- # source://json//lib/json/common.rb#575
963
- def recurse_proc(result, &proc); end
964
-
965
- # source://json//lib/json/common.rb#549
966
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
967
-
968
- # :stopdoc:
969
- # I want to deprecate these later, so I'll first be silent about them, and
970
- # later delete them.
978
+ # Returns the Ruby objects created by parsing the given +source+.
979
+ #
980
+ # BEWARE: This method is meant to serialise data from trusted user input,
981
+ # like from your own database server or clients under your control, it could
982
+ # be dangerous to allow untrusted users to pass JSON sources into it.
983
+ #
984
+ # - Argument +source+ must be, or be convertible to, a \String:
985
+ # - If +source+ responds to instance method +to_str+,
986
+ # <tt>source.to_str</tt> becomes the source.
987
+ # - If +source+ responds to instance method +to_io+,
988
+ # <tt>source.to_io.read</tt> becomes the source.
989
+ # - If +source+ responds to instance method +read+,
990
+ # <tt>source.read</tt> becomes the source.
991
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
992
+ # - Option +allow_blank+ specifies a truthy value.
993
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
994
+ # - Otherwise, +source+ remains the source.
995
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
996
+ # It will be called recursively with each result (depth-first order).
997
+ # See details below.
998
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
999
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1000
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1001
+ #
1002
+ # ---
1003
+ #
1004
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1005
+ # <tt>parse(source, opts)</tt>; see #parse.
1006
+ #
1007
+ # Source for following examples:
1008
+ # source = <<~JSON
1009
+ # {
1010
+ # "name": "Dave",
1011
+ # "age" :40,
1012
+ # "hats": [
1013
+ # "Cattleman's",
1014
+ # "Panama",
1015
+ # "Tophat"
1016
+ # ]
1017
+ # }
1018
+ # JSON
1019
+ #
1020
+ # Load a \String:
1021
+ # ruby = JSON.unsafe_load(source)
1022
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1023
+ #
1024
+ # Load an \IO object:
1025
+ # require 'stringio'
1026
+ # object = JSON.unsafe_load(StringIO.new(source))
1027
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1028
+ #
1029
+ # Load a \File object:
1030
+ # path = 't.json'
1031
+ # File.write(path, source)
1032
+ # File.open(path) do |file|
1033
+ # JSON.unsafe_load(file)
1034
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1035
+ #
1036
+ # ---
1037
+ #
1038
+ # When +proc+ is given:
1039
+ # - Modifies +source+ as above.
1040
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1041
+ # - Recursively calls <tt>proc(result)</tt>.
1042
+ # - Returns the final result.
1043
+ #
1044
+ # Example:
1045
+ # require 'json'
1046
+ #
1047
+ # # Some classes for the example.
1048
+ # class Base
1049
+ # def initialize(attributes)
1050
+ # @attributes = attributes
1051
+ # end
1052
+ # end
1053
+ # class User < Base; end
1054
+ # class Account < Base; end
1055
+ # class Admin < Base; end
1056
+ # # The JSON source.
1057
+ # json = <<-EOF
1058
+ # {
1059
+ # "users": [
1060
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1061
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1062
+ # ],
1063
+ # "accounts": [
1064
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1065
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1066
+ # ],
1067
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1068
+ # }
1069
+ # EOF
1070
+ # # Deserializer method.
1071
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1072
+ # type = obj.is_a?(Hash) && obj["type"]
1073
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1074
+ # end
1075
+ # # Call to JSON.unsafe_load
1076
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1077
+ # case obj
1078
+ # when Hash
1079
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1080
+ # when Array
1081
+ # obj.map! {|v| deserialize_obj v }
1082
+ # end
1083
+ # })
1084
+ # pp ruby
1085
+ # Output:
1086
+ # {"users"=>
1087
+ # [#<User:0x00000000064c4c98
1088
+ # @attributes=
1089
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1090
+ # #<User:0x00000000064c4bd0
1091
+ # @attributes=
1092
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1093
+ # "accounts"=>
1094
+ # [{"account"=>
1095
+ # #<Account:0x00000000064c4928
1096
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1097
+ # {"account"=>
1098
+ # #<Account:0x00000000064c4680
1099
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1100
+ # "admins"=>
1101
+ # #<Admin:0x00000000064c41f8
1102
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
971
1103
  #
972
- # source://json//lib/json/common.rb#308
973
- def unparse(obj, opts = T.unsafe(nil)); end
1104
+ # source://json//lib/json/common.rb#666
1105
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
974
1106
 
975
1107
  class << self
976
1108
  # :call-seq:
@@ -985,34 +1117,28 @@ module JSON
985
1117
  # ruby = [0, 1, nil]
986
1118
  # JSON[ruby] # => '[0,1,null]'
987
1119
  #
988
- # source://json//lib/json/common.rb#22
1120
+ # source://json//lib/json/common.rb#126
989
1121
  def [](object, opts = T.unsafe(nil)); end
990
1122
 
991
- # source://json//lib/json/common.rb#90
992
- def create_fast_state; end
993
-
994
1123
  # Returns the current create identifier.
995
1124
  # See also JSON.create_id=.
996
1125
  #
997
- # source://json//lib/json/common.rb#129
1126
+ # source://json//lib/json/common.rb#219
998
1127
  def create_id; end
999
1128
 
1000
1129
  # Sets create identifier, which is used to decide if the _json_create_
1001
1130
  # hook of a class should be called; initial value is +json_class+:
1002
1131
  # JSON.create_id # => 'json_class'
1003
1132
  #
1004
- # source://json//lib/json/common.rb#123
1133
+ # source://json//lib/json/common.rb#213
1005
1134
  def create_id=(new_value); end
1006
1135
 
1007
- # source://json//lib/json/common.rb#100
1008
- def create_pretty_state; end
1009
-
1010
1136
  # Return the constant located at _path_. The format of _path_ has to be
1011
1137
  # either ::A::B::C or A::B::C. In any case, A has to be located at the top
1012
1138
  # level (absolute namespace path?). If there doesn't exist a constant at
1013
1139
  # the given path, an ArgumentError is raised.
1014
1140
  #
1015
- # source://json//lib/json/common.rb#51
1141
+ # source://json//lib/json/common.rb#153
1016
1142
  def deep_const_get(path); end
1017
1143
 
1018
1144
  # :call-seq:
@@ -1043,25 +1169,9 @@ module JSON
1043
1169
  # Output:
1044
1170
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1045
1171
  #
1046
- # source://json//lib/json/common.rb#630
1172
+ # source://json//lib/json/common.rb#892
1047
1173
  def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1048
1174
 
1049
- # Sets or returns the default options for the JSON.dump method.
1050
- # Initially:
1051
- # opts = JSON.dump_default_options
1052
- # opts # => {:max_nesting=>false, :allow_nan=>true}
1053
- #
1054
- # source://json//lib/json/common.rb#596
1055
- def dump_default_options; end
1056
-
1057
- # Sets or returns the default options for the JSON.dump method.
1058
- # Initially:
1059
- # opts = JSON.dump_default_options
1060
- # opts # => {:max_nesting=>false, :allow_nan=>true}
1061
- #
1062
- # source://json//lib/json/common.rb#596
1063
- def dump_default_options=(_arg0); end
1064
-
1065
1175
  # :call-seq:
1066
1176
  # JSON.fast_generate(obj, opts) -> new_string
1067
1177
  #
@@ -1076,14 +1186,11 @@ module JSON
1076
1186
  # # Raises SystemStackError (stack level too deep):
1077
1187
  # JSON.fast_generate(a)
1078
1188
  #
1079
- # source://json//lib/json/common.rb#337
1189
+ # source://json//lib/json/common.rb#445
1080
1190
  def fast_generate(obj, opts = T.unsafe(nil)); end
1081
1191
 
1082
- # :stopdoc:
1083
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1084
- #
1085
- # source://json//lib/json/common.rb#337
1086
- def fast_unparse(obj, opts = T.unsafe(nil)); end
1192
+ # source://json//lib/json/common.rb#937
1193
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
1087
1194
 
1088
1195
  # :call-seq:
1089
1196
  # JSON.generate(obj, opts = nil) -> new_string
@@ -1121,31 +1228,34 @@ module JSON
1121
1228
  # # Raises JSON::NestingError (nesting of 100 is too deep):
1122
1229
  # JSON.generate(a)
1123
1230
  #
1124
- # source://json//lib/json/common.rb#308
1231
+ # source://json//lib/json/common.rb#424
1125
1232
  def generate(obj, opts = T.unsafe(nil)); end
1126
1233
 
1127
- # Returns the JSON generator module that is used by JSON. This is
1128
- # either JSON::Ext::Generator or JSON::Pure::Generator:
1129
- # JSON.generator # => JSON::Ext::Generator
1234
+ # Returns the JSON generator module that is used by JSON.
1130
1235
  #
1131
- # source://json//lib/json/common.rb#112
1236
+ # source://json//lib/json/common.rb#181
1132
1237
  def generator; end
1133
1238
 
1134
1239
  # Set the module _generator_ to be used by JSON.
1135
1240
  #
1136
- # source://json//lib/json/common.rb#67
1241
+ # source://json//lib/json/common.rb#160
1137
1242
  def generator=(generator); end
1138
1243
 
1139
- # Encodes string using String.encode.
1140
- #
1141
- # source://json//lib/json/common.rb#670
1142
- def iconv(to, from, string); end
1143
-
1144
1244
  # :call-seq:
1145
1245
  # JSON.load(source, proc = nil, options = {}) -> object
1146
1246
  #
1147
1247
  # Returns the Ruby objects created by parsing the given +source+.
1148
1248
  #
1249
+ # BEWARE: This method is meant to serialise data from trusted user input,
1250
+ # like from your own database server or clients under your control, it could
1251
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1252
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
1253
+ #
1254
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
1255
+ # non native type is deserialized, without `create_additions` being explicitly
1256
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
1257
+ # by default.
1258
+ #
1149
1259
  # - Argument +source+ must be, or be convertible to, a \String:
1150
1260
  # - If +source+ responds to instance method +to_str+,
1151
1261
  # <tt>source.to_str</tt> becomes the source.
@@ -1160,9 +1270,6 @@ module JSON
1160
1270
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1161
1271
  # It will be called recursively with each result (depth-first order).
1162
1272
  # See details below.
1163
- # BEWARE: This method is meant to serialise data from trusted user input,
1164
- # like from your own database server or clients under your control, it could
1165
- # be dangerous to allow untrusted users to pass JSON sources into it.
1166
1273
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1167
1274
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1168
1275
  # The default options can be changed via method JSON.load_default_options=.
@@ -1173,17 +1280,17 @@ module JSON
1173
1280
  # <tt>parse(source, opts)</tt>; see #parse.
1174
1281
  #
1175
1282
  # Source for following examples:
1176
- # source = <<-EOT
1177
- # {
1178
- # "name": "Dave",
1179
- # "age" :40,
1180
- # "hats": [
1181
- # "Cattleman's",
1182
- # "Panama",
1183
- # "Tophat"
1184
- # ]
1185
- # }
1186
- # EOT
1283
+ # source = <<~JSON
1284
+ # {
1285
+ # "name": "Dave",
1286
+ # "age" :40,
1287
+ # "hats": [
1288
+ # "Cattleman's",
1289
+ # "Panama",
1290
+ # "Tophat"
1291
+ # ]
1292
+ # }
1293
+ # JSON
1187
1294
  #
1188
1295
  # Load a \String:
1189
1296
  # ruby = JSON.load(source)
@@ -1269,25 +1376,9 @@ module JSON
1269
1376
  # #<Admin:0x00000000064c41f8
1270
1377
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1271
1378
  #
1272
- # source://json//lib/json/common.rb#549
1379
+ # source://json//lib/json/common.rb#826
1273
1380
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1274
1381
 
1275
- # Sets or returns default options for the JSON.load method.
1276
- # Initially:
1277
- # opts = JSON.load_default_options
1278
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1279
- #
1280
- # source://json//lib/json/common.rb#412
1281
- def load_default_options; end
1282
-
1283
- # Sets or returns default options for the JSON.load method.
1284
- # Initially:
1285
- # opts = JSON.load_default_options
1286
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1287
- #
1288
- # source://json//lib/json/common.rb#412
1289
- def load_default_options=(_arg0); end
1290
-
1291
1382
  # :call-seq:
1292
1383
  # JSON.load_file(path, opts={}) -> object
1293
1384
  #
@@ -1296,7 +1387,7 @@ module JSON
1296
1387
  #
1297
1388
  # See method #parse.
1298
1389
  #
1299
- # source://json//lib/json/common.rb#257
1390
+ # source://json//lib/json/common.rb#373
1300
1391
  def load_file(filespec, opts = T.unsafe(nil)); end
1301
1392
 
1302
1393
  # :call-seq:
@@ -1307,7 +1398,7 @@ module JSON
1307
1398
  #
1308
1399
  # See method #parse!
1309
1400
  #
1310
- # source://json//lib/json/common.rb#268
1401
+ # source://json//lib/json/common.rb#384
1311
1402
  def load_file!(filespec, opts = T.unsafe(nil)); end
1312
1403
 
1313
1404
  # :call-seq:
@@ -1338,17 +1429,17 @@ module JSON
1338
1429
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1339
1430
  #
1340
1431
  # Parses nested JSON objects:
1341
- # source = <<-EOT
1342
- # {
1343
- # "name": "Dave",
1344
- # "age" :40,
1345
- # "hats": [
1346
- # "Cattleman's",
1347
- # "Panama",
1348
- # "Tophat"
1349
- # ]
1350
- # }
1351
- # EOT
1432
+ # source = <<~JSON
1433
+ # {
1434
+ # "name": "Dave",
1435
+ # "age" :40,
1436
+ # "hats": [
1437
+ # "Cattleman's",
1438
+ # "Panama",
1439
+ # "Tophat"
1440
+ # ]
1441
+ # }
1442
+ # JSON
1352
1443
  # ruby = JSON.parse(source)
1353
1444
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1354
1445
  #
@@ -1358,7 +1449,7 @@ module JSON
1358
1449
  # # Raises JSON::ParserError (783: unexpected token at ''):
1359
1450
  # JSON.parse('')
1360
1451
  #
1361
- # source://json//lib/json/common.rb#218
1452
+ # source://json//lib/json/common.rb#336
1362
1453
  def parse(source, opts = T.unsafe(nil)); end
1363
1454
 
1364
1455
  # :call-seq:
@@ -1373,19 +1464,17 @@ module JSON
1373
1464
  # which disables checking for nesting depth.
1374
1465
  # - Option +allow_nan+, if not provided, defaults to +true+.
1375
1466
  #
1376
- # source://json//lib/json/common.rb#242
1467
+ # source://json//lib/json/common.rb#358
1377
1468
  def parse!(source, opts = T.unsafe(nil)); end
1378
1469
 
1379
- # Returns the JSON parser class that is used by JSON. This is either
1380
- # JSON::Ext::Parser or JSON::Pure::Parser:
1381
- # JSON.parser # => JSON::Ext::Parser
1470
+ # Returns the JSON parser class that is used by JSON.
1382
1471
  #
1383
- # source://json//lib/json/common.rb#38
1472
+ # source://json//lib/json/common.rb#140
1384
1473
  def parser; end
1385
1474
 
1386
1475
  # Set the JSON parser class _parser_ to be used by JSON.
1387
1476
  #
1388
- # source://json//lib/json/common.rb#41
1477
+ # source://json//lib/json/common.rb#143
1389
1478
  def parser=(parser); end
1390
1479
 
1391
1480
  # :call-seq:
@@ -1418,51 +1507,261 @@ module JSON
1418
1507
  # }
1419
1508
  # }
1420
1509
  #
1421
- # source://json//lib/json/common.rb#382
1510
+ # source://json//lib/json/common.rb#492
1422
1511
  def pretty_generate(obj, opts = T.unsafe(nil)); end
1423
1512
 
1424
- # :stopdoc:
1425
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1426
- #
1427
- # source://json//lib/json/common.rb#382
1428
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
1429
-
1430
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1431
- #
1432
- # source://json//lib/json/common.rb#575
1433
- def recurse_proc(result, &proc); end
1513
+ # source://json//lib/json/common.rb#947
1514
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1434
1515
 
1435
- # source://json//lib/json/common.rb#549
1436
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1516
+ # source://json//lib/json/common.rb#957
1517
+ def restore(*_arg0, **_arg1, &_arg2); end
1437
1518
 
1438
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1439
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1440
- # JSON.state # => JSON::Ext::Generator::State
1519
+ # Sets or Returns the JSON generator state class that is used by JSON.
1441
1520
  #
1442
- # source://json//lib/json/common.rb#117
1521
+ # source://json//lib/json/common.rb#184
1443
1522
  def state; end
1444
1523
 
1445
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1446
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1447
- # JSON.state # => JSON::Ext::Generator::State
1524
+ # Sets or Returns the JSON generator state class that is used by JSON.
1448
1525
  #
1449
- # source://json//lib/json/common.rb#117
1526
+ # source://json//lib/json/common.rb#184
1450
1527
  def state=(_arg0); end
1451
1528
 
1452
1529
  # :stopdoc:
1453
- # I want to deprecate these later, so I'll first be silent about them, and
1454
- # later delete them.
1530
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1531
+ # so usage still exist in the wild.
1532
+ #
1533
+ # source://json//lib/json/common.rb#927
1534
+ def unparse(*_arg0, **_arg1, &_arg2); end
1535
+
1536
+ # :call-seq:
1537
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
1538
+ #
1539
+ # Returns the Ruby objects created by parsing the given +source+.
1540
+ #
1541
+ # BEWARE: This method is meant to serialise data from trusted user input,
1542
+ # like from your own database server or clients under your control, it could
1543
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1544
+ #
1545
+ # - Argument +source+ must be, or be convertible to, a \String:
1546
+ # - If +source+ responds to instance method +to_str+,
1547
+ # <tt>source.to_str</tt> becomes the source.
1548
+ # - If +source+ responds to instance method +to_io+,
1549
+ # <tt>source.to_io.read</tt> becomes the source.
1550
+ # - If +source+ responds to instance method +read+,
1551
+ # <tt>source.read</tt> becomes the source.
1552
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1553
+ # - Option +allow_blank+ specifies a truthy value.
1554
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1555
+ # - Otherwise, +source+ remains the source.
1556
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1557
+ # It will be called recursively with each result (depth-first order).
1558
+ # See details below.
1559
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1560
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1561
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1562
+ #
1563
+ # ---
1564
+ #
1565
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1566
+ # <tt>parse(source, opts)</tt>; see #parse.
1567
+ #
1568
+ # Source for following examples:
1569
+ # source = <<~JSON
1570
+ # {
1571
+ # "name": "Dave",
1572
+ # "age" :40,
1573
+ # "hats": [
1574
+ # "Cattleman's",
1575
+ # "Panama",
1576
+ # "Tophat"
1577
+ # ]
1578
+ # }
1579
+ # JSON
1580
+ #
1581
+ # Load a \String:
1582
+ # ruby = JSON.unsafe_load(source)
1583
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1584
+ #
1585
+ # Load an \IO object:
1586
+ # require 'stringio'
1587
+ # object = JSON.unsafe_load(StringIO.new(source))
1588
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1589
+ #
1590
+ # Load a \File object:
1591
+ # path = 't.json'
1592
+ # File.write(path, source)
1593
+ # File.open(path) do |file|
1594
+ # JSON.unsafe_load(file)
1595
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1596
+ #
1597
+ # ---
1598
+ #
1599
+ # When +proc+ is given:
1600
+ # - Modifies +source+ as above.
1601
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1602
+ # - Recursively calls <tt>proc(result)</tt>.
1603
+ # - Returns the final result.
1604
+ #
1605
+ # Example:
1606
+ # require 'json'
1607
+ #
1608
+ # # Some classes for the example.
1609
+ # class Base
1610
+ # def initialize(attributes)
1611
+ # @attributes = attributes
1612
+ # end
1613
+ # end
1614
+ # class User < Base; end
1615
+ # class Account < Base; end
1616
+ # class Admin < Base; end
1617
+ # # The JSON source.
1618
+ # json = <<-EOF
1619
+ # {
1620
+ # "users": [
1621
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1622
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1623
+ # ],
1624
+ # "accounts": [
1625
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1626
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1627
+ # ],
1628
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1629
+ # }
1630
+ # EOF
1631
+ # # Deserializer method.
1632
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1633
+ # type = obj.is_a?(Hash) && obj["type"]
1634
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1635
+ # end
1636
+ # # Call to JSON.unsafe_load
1637
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1638
+ # case obj
1639
+ # when Hash
1640
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1641
+ # when Array
1642
+ # obj.map! {|v| deserialize_obj v }
1643
+ # end
1644
+ # })
1645
+ # pp ruby
1646
+ # Output:
1647
+ # {"users"=>
1648
+ # [#<User:0x00000000064c4c98
1649
+ # @attributes=
1650
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1651
+ # #<User:0x00000000064c4bd0
1652
+ # @attributes=
1653
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1654
+ # "accounts"=>
1655
+ # [{"account"=>
1656
+ # #<Account:0x00000000064c4928
1657
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1658
+ # {"account"=>
1659
+ # #<Account:0x00000000064c4680
1660
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1661
+ # "admins"=>
1662
+ # #<Admin:0x00000000064c41f8
1663
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1455
1664
  #
1456
- # source://json//lib/json/common.rb#308
1457
- def unparse(obj, opts = T.unsafe(nil)); end
1665
+ # source://json//lib/json/common.rb#666
1666
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1458
1667
 
1459
1668
  private
1460
1669
 
1461
- # source://json//lib/json/common.rb#674
1462
- def merge_dump_options(opts, strict: T.unsafe(nil)); end
1670
+ # source://json//lib/json/common.rb#970
1671
+ def const_missing(const_name); end
1672
+
1673
+ # source://json//lib/json/common.rb#188
1674
+ def deprecated_singleton_attr_accessor(*attrs); end
1463
1675
  end
1464
1676
  end
1465
1677
 
1678
+ # JSON::Coder holds a parser and generator configuration.
1679
+ #
1680
+ # module MyApp
1681
+ # JSONC_CODER = JSON::Coder.new(
1682
+ # allow_trailing_comma: true
1683
+ # )
1684
+ # end
1685
+ #
1686
+ # MyApp::JSONC_CODER.load(document)
1687
+ #
1688
+ # source://json//lib/json/common.rb#996
1689
+ class JSON::Coder
1690
+ # :call-seq:
1691
+ # JSON.new(options = nil, &block)
1692
+ #
1693
+ # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
1694
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options].
1695
+ #
1696
+ # For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
1697
+ # encoutered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
1698
+ # \JSON counterpart:
1699
+ #
1700
+ # module MyApp
1701
+ # API_JSON_CODER = JSON::Coder.new do |object|
1702
+ # case object
1703
+ # when Time
1704
+ # object.iso8601(3)
1705
+ # else
1706
+ # object # Unknown type, will raise
1707
+ # end
1708
+ # end
1709
+ # end
1710
+ #
1711
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
1712
+ #
1713
+ # @return [Coder] a new instance of Coder
1714
+ #
1715
+ # source://json//lib/json/common.rb#1020
1716
+ def initialize(options = T.unsafe(nil), &as_json); end
1717
+
1718
+ # call-seq:
1719
+ # dump(object) -> String
1720
+ # dump(object, io) -> io
1721
+ #
1722
+ # Serialize the given object into a \JSON document.
1723
+ #
1724
+ # source://json//lib/json/common.rb#1038
1725
+ def dump(object, io = T.unsafe(nil)); end
1726
+
1727
+ # call-seq:
1728
+ # dump(object) -> String
1729
+ # dump(object, io) -> io
1730
+ #
1731
+ # Serialize the given object into a \JSON document.
1732
+ #
1733
+ # source://json//lib/json/common.rb#1038
1734
+ def generate(object, io = T.unsafe(nil)); end
1735
+
1736
+ # call-seq:
1737
+ # load(string) -> Object
1738
+ #
1739
+ # Parse the given \JSON document and return an equivalent Ruby object.
1740
+ #
1741
+ # source://json//lib/json/common.rb#1047
1742
+ def load(source); end
1743
+
1744
+ # call-seq:
1745
+ # load(path) -> Object
1746
+ #
1747
+ # Parse the given \JSON document and return an equivalent Ruby object.
1748
+ #
1749
+ # source://json//lib/json/common.rb#1056
1750
+ def load_file(path); end
1751
+
1752
+ # call-seq:
1753
+ # load(string) -> Object
1754
+ #
1755
+ # Parse the given \JSON document and return an equivalent Ruby object.
1756
+ #
1757
+ # source://json//lib/json/common.rb#1047
1758
+ def parse(source); end
1759
+ end
1760
+
1761
+ module JSON::Ext::Generator::GeneratorMethods::String
1762
+ mixes_in_class_methods ::JSON::Ext::Generator::GeneratorMethods::String::Extend
1763
+ end
1764
+
1466
1765
  # source://json//lib/json/ext/generator/state.rb#6
1467
1766
  class JSON::Ext::Generator::State
1468
1767
  # call-seq: new(opts = {})
@@ -1493,14 +1792,14 @@ class JSON::Ext::Generator::State
1493
1792
  #
1494
1793
  # Returns the value returned by method +name+.
1495
1794
  #
1496
- # source://json//lib/json/ext/generator/state.rb#113
1795
+ # source://json//lib/json/ext/generator/state.rb#84
1497
1796
  def [](name); end
1498
1797
 
1499
1798
  # call-seq: []=(name, value)
1500
1799
  #
1501
1800
  # Sets the attribute name to value.
1502
1801
  #
1503
- # source://json//lib/json/ext/generator/state.rb#125
1802
+ # source://json//lib/json/ext/generator/state.rb#96
1504
1803
  def []=(name, value); end
1505
1804
 
1506
1805
  # call-seq: configure(opts)
@@ -1524,7 +1823,7 @@ class JSON::Ext::Generator::State
1524
1823
  # Returns the configuration instance variables as a hash, that can be
1525
1824
  # passed to the configure method.
1526
1825
  #
1527
- # source://json//lib/json/ext/generator/state.rb#84
1826
+ # source://json//lib/json/ext/generator/state.rb#54
1528
1827
  def to_h; end
1529
1828
 
1530
1829
  # call-seq: to_h
@@ -1532,10 +1831,86 @@ class JSON::Ext::Generator::State
1532
1831
  # Returns the configuration instance variables as a hash, that can be
1533
1832
  # passed to the configure method.
1534
1833
  #
1535
- # source://json//lib/json/ext/generator/state.rb#84
1834
+ # source://json//lib/json/ext/generator/state.rb#54
1536
1835
  def to_hash; end
1537
1836
  end
1538
1837
 
1838
+ # source://json//lib/json/ext.rb#9
1839
+ class JSON::Ext::Parser
1840
+ # @return [Parser] a new instance of Parser
1841
+ #
1842
+ # source://json//lib/json/ext.rb#17
1843
+ def initialize(source, opts = T.unsafe(nil)); end
1844
+
1845
+ # source://json//lib/json/ext.rb#26
1846
+ def parse; end
1847
+
1848
+ # source://json//lib/json/ext.rb#22
1849
+ def source; end
1850
+ end
1851
+
1852
+ # source://json//lib/json/ext.rb#32
1853
+ JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
1854
+
1855
+ # Fragment of JSON document that is to be included as is:
1856
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
1857
+ # JSON.generate({ count: 3, items: fragments })
1858
+ #
1859
+ # This allows to easily assemble multiple JSON fragments that have
1860
+ # been persisted somewhere without having to parse them nor resorting
1861
+ # to string interpolation.
1862
+ #
1863
+ # Note: no validation is performed on the provided string. It is the
1864
+ # responsability of the caller to ensure the string contains valid JSON.
1865
+ #
1866
+ # source://json//lib/json/common.rb#272
1867
+ class JSON::Fragment < ::Struct
1868
+ # @return [Fragment] a new instance of Fragment
1869
+ #
1870
+ # source://json//lib/json/common.rb#273
1871
+ def initialize(json); end
1872
+
1873
+ # Returns the value of attribute json
1874
+ #
1875
+ # @return [Object] the current value of json
1876
+ def json; end
1877
+
1878
+ # Sets the attribute json
1879
+ #
1880
+ # @param value [Object] the value to set the attribute json to.
1881
+ # @return [Object] the newly set value
1882
+ def json=(_); end
1883
+
1884
+ # source://json//lib/json/common.rb#281
1885
+ def to_json(state = T.unsafe(nil), *_arg1); end
1886
+
1887
+ class << self
1888
+ def [](*_arg0); end
1889
+ def inspect; end
1890
+ def keyword_init?; end
1891
+ def members; end
1892
+ def new(*_arg0); end
1893
+ end
1894
+ end
1895
+
1896
+ # This exception is raised if a generator or unparser error occurs.
1897
+ #
1898
+ # source://json//lib/json/common.rb#242
1899
+ class JSON::GeneratorError < ::JSON::JSONError
1900
+ # @return [GeneratorError] a new instance of GeneratorError
1901
+ #
1902
+ # source://json//lib/json/common.rb#245
1903
+ def initialize(message, invalid_object = T.unsafe(nil)); end
1904
+
1905
+ # source://json//lib/json/common.rb#250
1906
+ def detailed_message(*_arg0, **_arg1, &_arg2); end
1907
+
1908
+ # Returns the value of attribute invalid_object.
1909
+ #
1910
+ # source://json//lib/json/common.rb#243
1911
+ def invalid_object; end
1912
+ end
1913
+
1539
1914
  # source://json//lib/json/generic_object.rb#9
1540
1915
  class JSON::GenericObject < ::OpenStruct
1541
1916
  # source://json//lib/json/generic_object.rb#67
@@ -1577,31 +1952,58 @@ class JSON::GenericObject < ::OpenStruct
1577
1952
  end
1578
1953
  end
1579
1954
 
1580
- # The base exception for JSON errors.
1955
+ # source://json//lib/json/common.rb#341
1956
+ JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
1957
+
1958
+ # source://json//lib/json/common.rb#454
1959
+ JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
1960
+
1961
+ # source://json//lib/json/common.rb#146
1962
+ JSON::Parser = JSON::Ext::Parser
1963
+
1964
+ # This exception is raised if a parser error occurs.
1581
1965
  #
1582
- # source://json//lib/json/common.rb#140
1583
- class JSON::JSONError < ::StandardError
1584
- class << self
1585
- # source://json//lib/json/common.rb#141
1586
- def wrap(exception); end
1587
- end
1966
+ # source://json//lib/json/common.rb#233
1967
+ class JSON::ParserError < ::JSON::JSONError
1968
+ # Returns the value of attribute column.
1969
+ #
1970
+ # source://json//lib/json/common.rb#234
1971
+ def column; end
1972
+
1973
+ # Returns the value of attribute line.
1974
+ #
1975
+ # source://json//lib/json/common.rb#234
1976
+ def line; end
1588
1977
  end
1589
1978
 
1590
- # source://json//lib/json/common.rb#7
1591
- JSON::NOT_SET = T.let(T.unsafe(nil), Object)
1979
+ # source://json//lib/json/common.rb#8
1980
+ module JSON::ParserOptions
1981
+ class << self
1982
+ # source://json//lib/json/common.rb#10
1983
+ def prepare(opts); end
1592
1984
 
1593
- # source://json//lib/json/common.rb#44
1594
- JSON::Parser = JSON::Ext::Parser
1985
+ private
1595
1986
 
1596
- # source://json//lib/json/common.rb#82
1597
- JSON::State = JSON::Ext::Generator::State
1987
+ # source://json//lib/json/common.rb#40
1988
+ def array_class_proc(array_class, on_load); end
1598
1989
 
1599
- # For backwards compatibility
1600
- #
1601
- # source://json//lib/json/common.rb#162
1602
- JSON::UnparserError = JSON::GeneratorError
1990
+ # TODO: exctract :create_additions support to another gem for version 3.0
1991
+ #
1992
+ # source://json//lib/json/common.rb#52
1993
+ def create_additions_proc(opts); end
1994
+
1995
+ # source://json//lib/json/common.rb#91
1996
+ def create_additions_warning; end
1997
+
1998
+ # source://json//lib/json/common.rb#29
1999
+ def object_class_proc(object_class, on_load); end
2000
+ end
2001
+ end
2002
+
2003
+ # source://json//lib/json/common.rb#175
2004
+ JSON::State = JSON::Ext::Generator::State
1603
2005
 
1604
- # source://json//lib/json/common.rb#684
2006
+ # source://json//lib/json/common.rb#1062
1605
2007
  module Kernel
1606
2008
  private
1607
2009
 
@@ -1612,18 +2014,38 @@ module Kernel
1612
2014
  # The _opts_ argument is passed through to generate/parse respectively. See
1613
2015
  # generate and parse for their documentation.
1614
2016
  #
1615
- # source://json//lib/json/common.rb#711
1616
- def JSON(object, *args); end
2017
+ # source://json//lib/json/common.rb#1101
2018
+ def JSON(object, opts = T.unsafe(nil)); end
1617
2019
 
1618
2020
  # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1619
2021
  # one line.
1620
2022
  #
1621
- # source://json//lib/json/common.rb#689
2023
+ # source://json//lib/json/common.rb#1067
1622
2024
  def j(*objs); end
1623
2025
 
1624
2026
  # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1625
2027
  # indentation and over many lines.
1626
2028
  #
1627
- # source://json//lib/json/common.rb#698
2029
+ # source://json//lib/json/common.rb#1082
1628
2030
  def jj(*objs); end
1629
2031
  end
2032
+
2033
+ class NilClass
2034
+ include ::JSON::Ext::Generator::GeneratorMethods::NilClass
2035
+ end
2036
+
2037
+ class Object < ::BasicObject
2038
+ include ::Kernel
2039
+ include ::PP::ObjectMixin
2040
+ include ::JSON::Ext::Generator::GeneratorMethods::Object
2041
+ end
2042
+
2043
+ class String
2044
+ include ::Comparable
2045
+ include ::JSON::Ext::Generator::GeneratorMethods::String
2046
+ extend ::JSON::Ext::Generator::GeneratorMethods::String::Extend
2047
+ end
2048
+
2049
+ class TrueClass
2050
+ include ::JSON::Ext::Generator::GeneratorMethods::TrueClass
2051
+ end