mangrove 0.31.0 → 0.34.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/README.md +107 -43
- data/lib/mangrove/result.rb +50 -0
- data/lib/mangrove/version.rb +1 -1
- data/sorbet/config +1 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/date@3.4.1.rbi +75 -0
- data/sorbet/rbi/gems/{docile@1.4.0.rbi → docile@1.4.1.rbi} +2 -1
- data/sorbet/rbi/gems/{erubi@1.12.0.rbi → erubi@1.13.1.rbi} +26 -17
- data/sorbet/rbi/gems/{json@2.7.2.rbi → json@2.9.1.rbi} +516 -134
- data/sorbet/rbi/gems/logger@1.6.5.rbi +940 -0
- data/sorbet/rbi/gems/{parallel@1.24.0.rbi → parallel@1.26.3.rbi} +31 -21
- data/sorbet/rbi/gems/{parser@3.3.2.0.rbi → parser@3.3.7.0.rbi} +23 -1736
- data/sorbet/rbi/gems/{prism@0.29.0.rbi → prism@1.3.0.rbi} +13817 -10401
- data/sorbet/rbi/gems/{psych@5.1.2.rbi → psych@5.2.3.rbi} +289 -236
- data/sorbet/rbi/gems/{racc@1.8.0.rbi → racc@1.8.1.rbi} +0 -4
- data/sorbet/rbi/gems/rbi@0.2.3.rbi +4542 -0
- data/sorbet/rbi/gems/rbs@3.8.1.rbi +6882 -0
- data/sorbet/rbi/gems/{rdoc@6.7.0.rbi → rdoc@6.11.0.rbi} +1115 -1058
- data/sorbet/rbi/gems/{regexp_parser@2.9.2.rbi → regexp_parser@2.10.0.rbi} +193 -170
- data/sorbet/rbi/gems/{rspec-core@3.13.0.rbi → rspec-core@3.13.2.rbi} +146 -280
- data/sorbet/rbi/gems/{rspec-expectations@3.13.0.rbi → rspec-expectations@3.13.3.rbi} +323 -294
- data/sorbet/rbi/gems/{rspec-mocks@3.13.1.rbi → rspec-mocks@3.13.2.rbi} +46 -46
- data/sorbet/rbi/gems/{rspec-support@3.13.1.rbi → rspec-support@3.13.2.rbi} +22 -22
- data/sorbet/rbi/gems/ruboclean@0.7.1.rbi +473 -0
- data/sorbet/rbi/gems/{rubocop-ast@1.31.3.rbi → rubocop-ast@1.37.0.rbi} +1293 -745
- data/sorbet/rbi/gems/{rubocop-rspec@2.30.0.rbi → rubocop-rspec@3.4.0.rbi} +341 -1073
- data/sorbet/rbi/gems/{rubocop@1.64.1.rbi → rubocop@1.70.0.rbi} +5693 -3796
- data/sorbet/rbi/gems/{simplecov-html@0.12.3.rbi → simplecov-html@0.13.1.rbi} +77 -68
- data/sorbet/rbi/gems/{spoom@1.3.2.rbi → spoom@1.5.1.rbi} +2306 -1701
- data/sorbet/rbi/gems/{stringio@3.1.0.rbi → stringio@3.1.2.rbi} +1 -0
- data/sorbet/rbi/gems/{tapioca@0.14.3.rbi → tapioca@0.16.8.rbi} +411 -332
- data/sorbet/rbi/gems/{thor@1.3.1.rbi → thor@1.3.2.rbi} +57 -31
- data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +132 -0
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
- data/sorbet/rbi/gems/{webrick@1.8.1.rbi → webrick@1.9.1.rbi} +92 -72
- data/sorbet/rbi/gems/{yard-sorbet@0.8.1.rbi → yard-sorbet@0.9.0.rbi} +36 -29
- data/sorbet/rbi/gems/{yard@0.9.36.rbi → yard@0.9.37.rbi} +393 -235
- metadata +39 -42
- data/sorbet/rbi/gems/rbi@0.1.13.rbi +0 -3078
- data/sorbet/rbi/gems/rexml@3.2.8.rbi +0 -4794
- data/sorbet/rbi/gems/ruboclean@0.6.0.rbi +0 -315
- data/sorbet/rbi/gems/rubocop-capybara@2.20.0.rbi +0 -1208
- data/sorbet/rbi/gems/rubocop-factory_bot@2.25.1.rbi +0 -928
- data/sorbet/rbi/gems/rubocop-rspec_rails@2.28.3.rbi +0 -911
- 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/{io-console@0.7.2.rbi → io-console@0.8.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{reline@0.5.8.rbi → reline@0.6.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{ruby-lsp@0.17.2.rbi → ruby-lsp@0.23.6.rbi} +0 -0
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
# Extends any Class to include _json_creatable?_ method.
|
9
9
|
#
|
10
|
-
# source://json//lib/json/common.rb#
|
10
|
+
# source://json//lib/json/common.rb#888
|
11
11
|
class Class < ::Module
|
12
12
|
# Returns true if this class can be used to create an instance
|
13
13
|
# from a serialised JSON string. The class has to implement a class
|
@@ -16,7 +16,7 @@ class Class < ::Module
|
|
16
16
|
#
|
17
17
|
# @return [Boolean]
|
18
18
|
#
|
19
|
-
# source://json//lib/json/common.rb#
|
19
|
+
# source://json//lib/json/common.rb#893
|
20
20
|
def json_creatable?; end
|
21
21
|
end
|
22
22
|
|
@@ -396,13 +396,13 @@ end
|
|
396
396
|
# json1 = JSON.generate(ruby)
|
397
397
|
# ruby1 = JSON.parse(json1, create_additions: true)
|
398
398
|
# # Make a nice display.
|
399
|
-
# display =
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
405
|
-
#
|
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
406
|
# EOT
|
407
407
|
# puts display
|
408
408
|
#
|
@@ -580,13 +580,13 @@ end
|
|
580
580
|
# json1 = JSON.generate(foo1)
|
581
581
|
# obj1 = JSON.parse(json1, create_additions: true)
|
582
582
|
# # Make a nice display.
|
583
|
-
# display =
|
584
|
-
#
|
585
|
-
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
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
590
|
# EOT
|
591
591
|
# puts display
|
592
592
|
#
|
@@ -599,7 +599,7 @@ end
|
|
599
599
|
# Without custom addition: "#<Foo:0x0000000006534e80>" (String)
|
600
600
|
# With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
|
601
601
|
#
|
602
|
-
# source://json//lib/json/version.rb#
|
602
|
+
# source://json//lib/json/version.rb#3
|
603
603
|
module JSON
|
604
604
|
private
|
605
605
|
|
@@ -631,7 +631,7 @@ module JSON
|
|
631
631
|
# Output:
|
632
632
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
633
633
|
#
|
634
|
-
# source://json//lib/json/common.rb#
|
634
|
+
# source://json//lib/json/common.rb#795
|
635
635
|
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
636
636
|
|
637
637
|
# :call-seq:
|
@@ -693,7 +693,7 @@ module JSON
|
|
693
693
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
694
694
|
# JSON.generate(a)
|
695
695
|
#
|
696
|
-
# source://json//lib/json/common.rb#
|
696
|
+
# source://json//lib/json/common.rb#301
|
697
697
|
def generate(obj, opts = T.unsafe(nil)); end
|
698
698
|
|
699
699
|
# :call-seq:
|
@@ -701,6 +701,16 @@ module JSON
|
|
701
701
|
#
|
702
702
|
# Returns the Ruby objects created by parsing the given +source+.
|
703
703
|
#
|
704
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
705
|
+
# like from your own database server or clients under your control, it could
|
706
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
707
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
708
|
+
#
|
709
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
710
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
711
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
712
|
+
# by default.
|
713
|
+
#
|
704
714
|
# - Argument +source+ must be, or be convertible to, a \String:
|
705
715
|
# - If +source+ responds to instance method +to_str+,
|
706
716
|
# <tt>source.to_str</tt> becomes the source.
|
@@ -715,9 +725,6 @@ module JSON
|
|
715
725
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
716
726
|
# It will be called recursively with each result (depth-first order).
|
717
727
|
# 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
728
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
722
729
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
723
730
|
# The default options can be changed via method JSON.load_default_options=.
|
@@ -728,17 +735,17 @@ module JSON
|
|
728
735
|
# <tt>parse(source, opts)</tt>; see #parse.
|
729
736
|
#
|
730
737
|
# Source for following examples:
|
731
|
-
# source =
|
732
|
-
#
|
733
|
-
#
|
734
|
-
#
|
735
|
-
#
|
736
|
-
#
|
737
|
-
#
|
738
|
-
#
|
739
|
-
#
|
740
|
-
#
|
741
|
-
#
|
738
|
+
# source = <<~JSON
|
739
|
+
# {
|
740
|
+
# "name": "Dave",
|
741
|
+
# "age" :40,
|
742
|
+
# "hats": [
|
743
|
+
# "Cattleman's",
|
744
|
+
# "Panama",
|
745
|
+
# "Tophat"
|
746
|
+
# ]
|
747
|
+
# }
|
748
|
+
# JSON
|
742
749
|
#
|
743
750
|
# Load a \String:
|
744
751
|
# ruby = JSON.load(source)
|
@@ -824,7 +831,7 @@ module JSON
|
|
824
831
|
# #<Admin:0x00000000064c41f8
|
825
832
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
826
833
|
#
|
827
|
-
# source://json//lib/json/common.rb#
|
834
|
+
# source://json//lib/json/common.rb#714
|
828
835
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
829
836
|
|
830
837
|
# :call-seq:
|
@@ -835,7 +842,7 @@ module JSON
|
|
835
842
|
#
|
836
843
|
# See method #parse.
|
837
844
|
#
|
838
|
-
# source://json//lib/json/common.rb#
|
845
|
+
# source://json//lib/json/common.rb#250
|
839
846
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
840
847
|
|
841
848
|
# :call-seq:
|
@@ -846,10 +853,10 @@ module JSON
|
|
846
853
|
#
|
847
854
|
# See method #parse!
|
848
855
|
#
|
849
|
-
# source://json//lib/json/common.rb#
|
856
|
+
# source://json//lib/json/common.rb#261
|
850
857
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
851
858
|
|
852
|
-
# source://json//lib/json/common.rb#
|
859
|
+
# source://json//lib/json/common.rb#836
|
853
860
|
def merge_dump_options(opts, strict: T.unsafe(nil)); end
|
854
861
|
|
855
862
|
# :call-seq:
|
@@ -880,17 +887,17 @@ module JSON
|
|
880
887
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
881
888
|
#
|
882
889
|
# Parses nested JSON objects:
|
883
|
-
# source =
|
884
|
-
#
|
885
|
-
#
|
886
|
-
#
|
887
|
-
#
|
888
|
-
#
|
889
|
-
#
|
890
|
-
#
|
891
|
-
#
|
892
|
-
#
|
893
|
-
#
|
890
|
+
# source = <<~JSON
|
891
|
+
# {
|
892
|
+
# "name": "Dave",
|
893
|
+
# "age" :40,
|
894
|
+
# "hats": [
|
895
|
+
# "Cattleman's",
|
896
|
+
# "Panama",
|
897
|
+
# "Tophat"
|
898
|
+
# ]
|
899
|
+
# }
|
900
|
+
# JSON
|
894
901
|
# ruby = JSON.parse(source)
|
895
902
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
896
903
|
#
|
@@ -900,7 +907,7 @@ module JSON
|
|
900
907
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
901
908
|
# JSON.parse('')
|
902
909
|
#
|
903
|
-
# source://json//lib/json/common.rb#
|
910
|
+
# source://json//lib/json/common.rb#220
|
904
911
|
def parse(source, opts = T.unsafe(nil)); end
|
905
912
|
|
906
913
|
# :call-seq:
|
@@ -915,7 +922,7 @@ module JSON
|
|
915
922
|
# which disables checking for nesting depth.
|
916
923
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
917
924
|
#
|
918
|
-
# source://json//lib/json/common.rb#
|
925
|
+
# source://json//lib/json/common.rb#235
|
919
926
|
def parse!(source, opts = T.unsafe(nil)); end
|
920
927
|
|
921
928
|
# :call-seq:
|
@@ -959,19 +966,151 @@ module JSON
|
|
959
966
|
|
960
967
|
# Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
|
961
968
|
#
|
962
|
-
# source://json//lib/json/common.rb#
|
969
|
+
# source://json//lib/json/common.rb#740
|
963
970
|
def recurse_proc(result, &proc); end
|
964
971
|
|
965
|
-
# source://json//lib/json/common.rb#
|
972
|
+
# source://json//lib/json/common.rb#714
|
966
973
|
def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
967
974
|
|
968
975
|
# :stopdoc:
|
969
976
|
# I want to deprecate these later, so I'll first be silent about them, and
|
970
977
|
# later delete them.
|
971
978
|
#
|
972
|
-
# source://json//lib/json/common.rb#
|
979
|
+
# source://json//lib/json/common.rb#301
|
973
980
|
def unparse(obj, opts = T.unsafe(nil)); end
|
974
981
|
|
982
|
+
# :call-seq:
|
983
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
984
|
+
#
|
985
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
986
|
+
#
|
987
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
988
|
+
# like from your own database server or clients under your control, it could
|
989
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
990
|
+
#
|
991
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
992
|
+
# - If +source+ responds to instance method +to_str+,
|
993
|
+
# <tt>source.to_str</tt> becomes the source.
|
994
|
+
# - If +source+ responds to instance method +to_io+,
|
995
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
996
|
+
# - If +source+ responds to instance method +read+,
|
997
|
+
# <tt>source.read</tt> becomes the source.
|
998
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
999
|
+
# - Option +allow_blank+ specifies a truthy value.
|
1000
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
1001
|
+
# - Otherwise, +source+ remains the source.
|
1002
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1003
|
+
# It will be called recursively with each result (depth-first order).
|
1004
|
+
# See details below.
|
1005
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1006
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1007
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
1008
|
+
#
|
1009
|
+
# ---
|
1010
|
+
#
|
1011
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
1012
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
1013
|
+
#
|
1014
|
+
# Source for following examples:
|
1015
|
+
# source = <<~JSON
|
1016
|
+
# {
|
1017
|
+
# "name": "Dave",
|
1018
|
+
# "age" :40,
|
1019
|
+
# "hats": [
|
1020
|
+
# "Cattleman's",
|
1021
|
+
# "Panama",
|
1022
|
+
# "Tophat"
|
1023
|
+
# ]
|
1024
|
+
# }
|
1025
|
+
# JSON
|
1026
|
+
#
|
1027
|
+
# Load a \String:
|
1028
|
+
# ruby = JSON.unsafe_load(source)
|
1029
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1030
|
+
#
|
1031
|
+
# Load an \IO object:
|
1032
|
+
# require 'stringio'
|
1033
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
1034
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1035
|
+
#
|
1036
|
+
# Load a \File object:
|
1037
|
+
# path = 't.json'
|
1038
|
+
# File.write(path, source)
|
1039
|
+
# File.open(path) do |file|
|
1040
|
+
# JSON.unsafe_load(file)
|
1041
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1042
|
+
#
|
1043
|
+
# ---
|
1044
|
+
#
|
1045
|
+
# When +proc+ is given:
|
1046
|
+
# - Modifies +source+ as above.
|
1047
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
1048
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
1049
|
+
# - Returns the final result.
|
1050
|
+
#
|
1051
|
+
# Example:
|
1052
|
+
# require 'json'
|
1053
|
+
#
|
1054
|
+
# # Some classes for the example.
|
1055
|
+
# class Base
|
1056
|
+
# def initialize(attributes)
|
1057
|
+
# @attributes = attributes
|
1058
|
+
# end
|
1059
|
+
# end
|
1060
|
+
# class User < Base; end
|
1061
|
+
# class Account < Base; end
|
1062
|
+
# class Admin < Base; end
|
1063
|
+
# # The JSON source.
|
1064
|
+
# json = <<-EOF
|
1065
|
+
# {
|
1066
|
+
# "users": [
|
1067
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
1068
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
1069
|
+
# ],
|
1070
|
+
# "accounts": [
|
1071
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
1072
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
1073
|
+
# ],
|
1074
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
1075
|
+
# }
|
1076
|
+
# EOF
|
1077
|
+
# # Deserializer method.
|
1078
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
1079
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
1080
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
1081
|
+
# end
|
1082
|
+
# # Call to JSON.unsafe_load
|
1083
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
1084
|
+
# case obj
|
1085
|
+
# when Hash
|
1086
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
1087
|
+
# when Array
|
1088
|
+
# obj.map! {|v| deserialize_obj v }
|
1089
|
+
# end
|
1090
|
+
# })
|
1091
|
+
# pp ruby
|
1092
|
+
# Output:
|
1093
|
+
# {"users"=>
|
1094
|
+
# [#<User:0x00000000064c4c98
|
1095
|
+
# @attributes=
|
1096
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
1097
|
+
# #<User:0x00000000064c4bd0
|
1098
|
+
# @attributes=
|
1099
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
1100
|
+
# "accounts"=>
|
1101
|
+
# [{"account"=>
|
1102
|
+
# #<Account:0x00000000064c4928
|
1103
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
1104
|
+
# {"account"=>
|
1105
|
+
# #<Account:0x00000000064c4680
|
1106
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
1107
|
+
# "admins"=>
|
1108
|
+
# #<Admin:0x00000000064c41f8
|
1109
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1110
|
+
#
|
1111
|
+
# source://json//lib/json/common.rb#554
|
1112
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1113
|
+
|
975
1114
|
class << self
|
976
1115
|
# :call-seq:
|
977
1116
|
# JSON[object] -> new_array or new_string
|
@@ -985,26 +1124,26 @@ module JSON
|
|
985
1124
|
# ruby = [0, 1, nil]
|
986
1125
|
# JSON[ruby] # => '[0,1,null]'
|
987
1126
|
#
|
988
|
-
# source://json//lib/json/common.rb#
|
1127
|
+
# source://json//lib/json/common.rb#23
|
989
1128
|
def [](object, opts = T.unsafe(nil)); end
|
990
1129
|
|
991
|
-
# source://json//lib/json/common.rb#
|
1130
|
+
# source://json//lib/json/common.rb#80
|
992
1131
|
def create_fast_state; end
|
993
1132
|
|
994
1133
|
# Returns the current create identifier.
|
995
1134
|
# See also JSON.create_id=.
|
996
1135
|
#
|
997
|
-
# source://json//lib/json/common.rb#
|
1136
|
+
# source://json//lib/json/common.rb#115
|
998
1137
|
def create_id; end
|
999
1138
|
|
1000
1139
|
# Sets create identifier, which is used to decide if the _json_create_
|
1001
1140
|
# hook of a class should be called; initial value is +json_class+:
|
1002
1141
|
# JSON.create_id # => 'json_class'
|
1003
1142
|
#
|
1004
|
-
# source://json//lib/json/common.rb#
|
1143
|
+
# source://json//lib/json/common.rb#109
|
1005
1144
|
def create_id=(new_value); end
|
1006
1145
|
|
1007
|
-
# source://json//lib/json/common.rb#
|
1146
|
+
# source://json//lib/json/common.rb#90
|
1008
1147
|
def create_pretty_state; end
|
1009
1148
|
|
1010
1149
|
# Return the constant located at _path_. The format of _path_ has to be
|
@@ -1012,7 +1151,7 @@ module JSON
|
|
1012
1151
|
# level (absolute namespace path?). If there doesn't exist a constant at
|
1013
1152
|
# the given path, an ArgumentError is raised.
|
1014
1153
|
#
|
1015
|
-
# source://json//lib/json/common.rb#
|
1154
|
+
# source://json//lib/json/common.rb#50
|
1016
1155
|
def deep_const_get(path); end
|
1017
1156
|
|
1018
1157
|
# :call-seq:
|
@@ -1043,23 +1182,23 @@ module JSON
|
|
1043
1182
|
# Output:
|
1044
1183
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
1045
1184
|
#
|
1046
|
-
# source://json//lib/json/common.rb#
|
1185
|
+
# source://json//lib/json/common.rb#795
|
1047
1186
|
def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
|
1048
1187
|
|
1049
1188
|
# Sets or returns the default options for the JSON.dump method.
|
1050
1189
|
# Initially:
|
1051
1190
|
# opts = JSON.dump_default_options
|
1052
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true
|
1191
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true}
|
1053
1192
|
#
|
1054
|
-
# source://json//lib/json/common.rb#
|
1193
|
+
# source://json//lib/json/common.rb#761
|
1055
1194
|
def dump_default_options; end
|
1056
1195
|
|
1057
1196
|
# Sets or returns the default options for the JSON.dump method.
|
1058
1197
|
# Initially:
|
1059
1198
|
# opts = JSON.dump_default_options
|
1060
|
-
# opts # => {:max_nesting=>false, :allow_nan=>true
|
1199
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true}
|
1061
1200
|
#
|
1062
|
-
# source://json//lib/json/common.rb#
|
1201
|
+
# source://json//lib/json/common.rb#761
|
1063
1202
|
def dump_default_options=(_arg0); end
|
1064
1203
|
|
1065
1204
|
# :call-seq:
|
@@ -1121,24 +1260,22 @@ module JSON
|
|
1121
1260
|
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
1122
1261
|
# JSON.generate(a)
|
1123
1262
|
#
|
1124
|
-
# source://json//lib/json/common.rb#
|
1263
|
+
# source://json//lib/json/common.rb#301
|
1125
1264
|
def generate(obj, opts = T.unsafe(nil)); end
|
1126
1265
|
|
1127
|
-
# Returns the JSON generator module that is used by JSON.
|
1128
|
-
# either JSON::Ext::Generator or JSON::Pure::Generator:
|
1129
|
-
# JSON.generator # => JSON::Ext::Generator
|
1266
|
+
# Returns the JSON generator module that is used by JSON.
|
1130
1267
|
#
|
1131
|
-
# source://json//lib/json/common.rb#
|
1268
|
+
# source://json//lib/json/common.rb#100
|
1132
1269
|
def generator; end
|
1133
1270
|
|
1134
1271
|
# Set the module _generator_ to be used by JSON.
|
1135
1272
|
#
|
1136
|
-
# source://json//lib/json/common.rb#
|
1273
|
+
# source://json//lib/json/common.rb#57
|
1137
1274
|
def generator=(generator); end
|
1138
1275
|
|
1139
1276
|
# Encodes string using String.encode.
|
1140
1277
|
#
|
1141
|
-
# source://json//lib/json/common.rb#
|
1278
|
+
# source://json//lib/json/common.rb#832
|
1142
1279
|
def iconv(to, from, string); end
|
1143
1280
|
|
1144
1281
|
# :call-seq:
|
@@ -1146,6 +1283,16 @@ module JSON
|
|
1146
1283
|
#
|
1147
1284
|
# Returns the Ruby objects created by parsing the given +source+.
|
1148
1285
|
#
|
1286
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
1287
|
+
# like from your own database server or clients under your control, it could
|
1288
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
1289
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
1290
|
+
#
|
1291
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
1292
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
1293
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
1294
|
+
# by default.
|
1295
|
+
#
|
1149
1296
|
# - Argument +source+ must be, or be convertible to, a \String:
|
1150
1297
|
# - If +source+ responds to instance method +to_str+,
|
1151
1298
|
# <tt>source.to_str</tt> becomes the source.
|
@@ -1160,9 +1307,6 @@ module JSON
|
|
1160
1307
|
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1161
1308
|
# It will be called recursively with each result (depth-first order).
|
1162
1309
|
# 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
1310
|
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1167
1311
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1168
1312
|
# The default options can be changed via method JSON.load_default_options=.
|
@@ -1173,17 +1317,17 @@ module JSON
|
|
1173
1317
|
# <tt>parse(source, opts)</tt>; see #parse.
|
1174
1318
|
#
|
1175
1319
|
# Source for following examples:
|
1176
|
-
# source =
|
1177
|
-
#
|
1178
|
-
#
|
1179
|
-
#
|
1180
|
-
#
|
1181
|
-
#
|
1182
|
-
#
|
1183
|
-
#
|
1184
|
-
#
|
1185
|
-
#
|
1186
|
-
#
|
1320
|
+
# source = <<~JSON
|
1321
|
+
# {
|
1322
|
+
# "name": "Dave",
|
1323
|
+
# "age" :40,
|
1324
|
+
# "hats": [
|
1325
|
+
# "Cattleman's",
|
1326
|
+
# "Panama",
|
1327
|
+
# "Tophat"
|
1328
|
+
# ]
|
1329
|
+
# }
|
1330
|
+
# JSON
|
1187
1331
|
#
|
1188
1332
|
# Load a \String:
|
1189
1333
|
# ruby = JSON.load(source)
|
@@ -1269,7 +1413,7 @@ module JSON
|
|
1269
1413
|
# #<Admin:0x00000000064c41f8
|
1270
1414
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1271
1415
|
#
|
1272
|
-
# source://json//lib/json/common.rb#
|
1416
|
+
# source://json//lib/json/common.rb#714
|
1273
1417
|
def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1274
1418
|
|
1275
1419
|
# Sets or returns default options for the JSON.load method.
|
@@ -1277,7 +1421,7 @@ module JSON
|
|
1277
1421
|
# opts = JSON.load_default_options
|
1278
1422
|
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1279
1423
|
#
|
1280
|
-
# source://json//lib/json/common.rb#
|
1424
|
+
# source://json//lib/json/common.rb#418
|
1281
1425
|
def load_default_options; end
|
1282
1426
|
|
1283
1427
|
# Sets or returns default options for the JSON.load method.
|
@@ -1285,7 +1429,7 @@ module JSON
|
|
1285
1429
|
# opts = JSON.load_default_options
|
1286
1430
|
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1287
1431
|
#
|
1288
|
-
# source://json//lib/json/common.rb#
|
1432
|
+
# source://json//lib/json/common.rb#418
|
1289
1433
|
def load_default_options=(_arg0); end
|
1290
1434
|
|
1291
1435
|
# :call-seq:
|
@@ -1296,7 +1440,7 @@ module JSON
|
|
1296
1440
|
#
|
1297
1441
|
# See method #parse.
|
1298
1442
|
#
|
1299
|
-
# source://json//lib/json/common.rb#
|
1443
|
+
# source://json//lib/json/common.rb#250
|
1300
1444
|
def load_file(filespec, opts = T.unsafe(nil)); end
|
1301
1445
|
|
1302
1446
|
# :call-seq:
|
@@ -1307,7 +1451,7 @@ module JSON
|
|
1307
1451
|
#
|
1308
1452
|
# See method #parse!
|
1309
1453
|
#
|
1310
|
-
# source://json//lib/json/common.rb#
|
1454
|
+
# source://json//lib/json/common.rb#261
|
1311
1455
|
def load_file!(filespec, opts = T.unsafe(nil)); end
|
1312
1456
|
|
1313
1457
|
# :call-seq:
|
@@ -1338,17 +1482,17 @@ module JSON
|
|
1338
1482
|
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
1339
1483
|
#
|
1340
1484
|
# Parses nested JSON objects:
|
1341
|
-
# source =
|
1342
|
-
#
|
1343
|
-
#
|
1344
|
-
#
|
1345
|
-
#
|
1346
|
-
#
|
1347
|
-
#
|
1348
|
-
#
|
1349
|
-
#
|
1350
|
-
#
|
1351
|
-
#
|
1485
|
+
# source = <<~JSON
|
1486
|
+
# {
|
1487
|
+
# "name": "Dave",
|
1488
|
+
# "age" :40,
|
1489
|
+
# "hats": [
|
1490
|
+
# "Cattleman's",
|
1491
|
+
# "Panama",
|
1492
|
+
# "Tophat"
|
1493
|
+
# ]
|
1494
|
+
# }
|
1495
|
+
# JSON
|
1352
1496
|
# ruby = JSON.parse(source)
|
1353
1497
|
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1354
1498
|
#
|
@@ -1358,7 +1502,7 @@ module JSON
|
|
1358
1502
|
# # Raises JSON::ParserError (783: unexpected token at ''):
|
1359
1503
|
# JSON.parse('')
|
1360
1504
|
#
|
1361
|
-
# source://json//lib/json/common.rb#
|
1505
|
+
# source://json//lib/json/common.rb#220
|
1362
1506
|
def parse(source, opts = T.unsafe(nil)); end
|
1363
1507
|
|
1364
1508
|
# :call-seq:
|
@@ -1373,19 +1517,17 @@ module JSON
|
|
1373
1517
|
# which disables checking for nesting depth.
|
1374
1518
|
# - Option +allow_nan+, if not provided, defaults to +true+.
|
1375
1519
|
#
|
1376
|
-
# source://json//lib/json/common.rb#
|
1520
|
+
# source://json//lib/json/common.rb#235
|
1377
1521
|
def parse!(source, opts = T.unsafe(nil)); end
|
1378
1522
|
|
1379
|
-
# Returns the JSON parser class that is used by JSON.
|
1380
|
-
# JSON::Ext::Parser or JSON::Pure::Parser:
|
1381
|
-
# JSON.parser # => JSON::Ext::Parser
|
1523
|
+
# Returns the JSON parser class that is used by JSON.
|
1382
1524
|
#
|
1383
|
-
# source://json//lib/json/common.rb#
|
1525
|
+
# source://json//lib/json/common.rb#37
|
1384
1526
|
def parser; end
|
1385
1527
|
|
1386
1528
|
# Set the JSON parser class _parser_ to be used by JSON.
|
1387
1529
|
#
|
1388
|
-
# source://json//lib/json/common.rb#
|
1530
|
+
# source://json//lib/json/common.rb#40
|
1389
1531
|
def parser=(parser); end
|
1390
1532
|
|
1391
1533
|
# :call-seq:
|
@@ -1429,45 +1571,285 @@ module JSON
|
|
1429
1571
|
|
1430
1572
|
# Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
|
1431
1573
|
#
|
1432
|
-
# source://json//lib/json/common.rb#
|
1574
|
+
# source://json//lib/json/common.rb#740
|
1433
1575
|
def recurse_proc(result, &proc); end
|
1434
1576
|
|
1435
|
-
# source://json//lib/json/common.rb#
|
1577
|
+
# source://json//lib/json/common.rb#714
|
1436
1578
|
def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1437
1579
|
|
1438
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
1439
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
1440
|
-
# JSON.state # => JSON::Ext::Generator::State
|
1580
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
1441
1581
|
#
|
1442
|
-
# source://json//lib/json/common.rb#
|
1582
|
+
# source://json//lib/json/common.rb#103
|
1443
1583
|
def state; end
|
1444
1584
|
|
1445
|
-
# Sets or Returns the JSON generator state class that is used by JSON.
|
1446
|
-
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
|
1447
|
-
# JSON.state # => JSON::Ext::Generator::State
|
1585
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
1448
1586
|
#
|
1449
|
-
# source://json//lib/json/common.rb#
|
1587
|
+
# source://json//lib/json/common.rb#103
|
1450
1588
|
def state=(_arg0); end
|
1451
1589
|
|
1452
1590
|
# :stopdoc:
|
1453
1591
|
# I want to deprecate these later, so I'll first be silent about them, and
|
1454
1592
|
# later delete them.
|
1455
1593
|
#
|
1456
|
-
# source://json//lib/json/common.rb#
|
1594
|
+
# source://json//lib/json/common.rb#301
|
1457
1595
|
def unparse(obj, opts = T.unsafe(nil)); end
|
1458
1596
|
|
1597
|
+
# :call-seq:
|
1598
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
1599
|
+
#
|
1600
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
1601
|
+
#
|
1602
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
1603
|
+
# like from your own database server or clients under your control, it could
|
1604
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
1605
|
+
#
|
1606
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
1607
|
+
# - If +source+ responds to instance method +to_str+,
|
1608
|
+
# <tt>source.to_str</tt> becomes the source.
|
1609
|
+
# - If +source+ responds to instance method +to_io+,
|
1610
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
1611
|
+
# - If +source+ responds to instance method +read+,
|
1612
|
+
# <tt>source.read</tt> becomes the source.
|
1613
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
1614
|
+
# - Option +allow_blank+ specifies a truthy value.
|
1615
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
1616
|
+
# - Otherwise, +source+ remains the source.
|
1617
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
1618
|
+
# It will be called recursively with each result (depth-first order).
|
1619
|
+
# See details below.
|
1620
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
1621
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
1622
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
1623
|
+
#
|
1624
|
+
# ---
|
1625
|
+
#
|
1626
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
1627
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
1628
|
+
#
|
1629
|
+
# Source for following examples:
|
1630
|
+
# source = <<~JSON
|
1631
|
+
# {
|
1632
|
+
# "name": "Dave",
|
1633
|
+
# "age" :40,
|
1634
|
+
# "hats": [
|
1635
|
+
# "Cattleman's",
|
1636
|
+
# "Panama",
|
1637
|
+
# "Tophat"
|
1638
|
+
# ]
|
1639
|
+
# }
|
1640
|
+
# JSON
|
1641
|
+
#
|
1642
|
+
# Load a \String:
|
1643
|
+
# ruby = JSON.unsafe_load(source)
|
1644
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1645
|
+
#
|
1646
|
+
# Load an \IO object:
|
1647
|
+
# require 'stringio'
|
1648
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
1649
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1650
|
+
#
|
1651
|
+
# Load a \File object:
|
1652
|
+
# path = 't.json'
|
1653
|
+
# File.write(path, source)
|
1654
|
+
# File.open(path) do |file|
|
1655
|
+
# JSON.unsafe_load(file)
|
1656
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
1657
|
+
#
|
1658
|
+
# ---
|
1659
|
+
#
|
1660
|
+
# When +proc+ is given:
|
1661
|
+
# - Modifies +source+ as above.
|
1662
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
1663
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
1664
|
+
# - Returns the final result.
|
1665
|
+
#
|
1666
|
+
# Example:
|
1667
|
+
# require 'json'
|
1668
|
+
#
|
1669
|
+
# # Some classes for the example.
|
1670
|
+
# class Base
|
1671
|
+
# def initialize(attributes)
|
1672
|
+
# @attributes = attributes
|
1673
|
+
# end
|
1674
|
+
# end
|
1675
|
+
# class User < Base; end
|
1676
|
+
# class Account < Base; end
|
1677
|
+
# class Admin < Base; end
|
1678
|
+
# # The JSON source.
|
1679
|
+
# json = <<-EOF
|
1680
|
+
# {
|
1681
|
+
# "users": [
|
1682
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
1683
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
1684
|
+
# ],
|
1685
|
+
# "accounts": [
|
1686
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
1687
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
1688
|
+
# ],
|
1689
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
1690
|
+
# }
|
1691
|
+
# EOF
|
1692
|
+
# # Deserializer method.
|
1693
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
1694
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
1695
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
1696
|
+
# end
|
1697
|
+
# # Call to JSON.unsafe_load
|
1698
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
1699
|
+
# case obj
|
1700
|
+
# when Hash
|
1701
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
1702
|
+
# when Array
|
1703
|
+
# obj.map! {|v| deserialize_obj v }
|
1704
|
+
# end
|
1705
|
+
# })
|
1706
|
+
# pp ruby
|
1707
|
+
# Output:
|
1708
|
+
# {"users"=>
|
1709
|
+
# [#<User:0x00000000064c4c98
|
1710
|
+
# @attributes=
|
1711
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
1712
|
+
# #<User:0x00000000064c4bd0
|
1713
|
+
# @attributes=
|
1714
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
1715
|
+
# "accounts"=>
|
1716
|
+
# [{"account"=>
|
1717
|
+
# #<Account:0x00000000064c4928
|
1718
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
1719
|
+
# {"account"=>
|
1720
|
+
# #<Account:0x00000000064c4680
|
1721
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
1722
|
+
# "admins"=>
|
1723
|
+
# #<Admin:0x00000000064c41f8
|
1724
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
1725
|
+
#
|
1726
|
+
# source://json//lib/json/common.rb#554
|
1727
|
+
def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
|
1728
|
+
|
1729
|
+
# Sets or returns default options for the JSON.unsafe_load method.
|
1730
|
+
# Initially:
|
1731
|
+
# opts = JSON.load_default_options
|
1732
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1733
|
+
#
|
1734
|
+
# source://json//lib/json/common.rb#404
|
1735
|
+
def unsafe_load_default_options; end
|
1736
|
+
|
1737
|
+
# Sets or returns default options for the JSON.unsafe_load method.
|
1738
|
+
# Initially:
|
1739
|
+
# opts = JSON.load_default_options
|
1740
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1741
|
+
#
|
1742
|
+
# source://json//lib/json/common.rb#404
|
1743
|
+
def unsafe_load_default_options=(_arg0); end
|
1744
|
+
|
1459
1745
|
private
|
1460
1746
|
|
1461
|
-
# source://json//lib/json/common.rb#
|
1747
|
+
# source://json//lib/json/common.rb#836
|
1462
1748
|
def merge_dump_options(opts, strict: T.unsafe(nil)); end
|
1463
1749
|
end
|
1464
1750
|
end
|
1465
1751
|
|
1466
|
-
# source://json//lib/json/
|
1467
|
-
JSON::
|
1752
|
+
# source://json//lib/json/ext/generator/state.rb#6
|
1753
|
+
class JSON::Ext::Generator::State
|
1754
|
+
# call-seq: new(opts = {})
|
1755
|
+
#
|
1756
|
+
# Instantiates a new State object, configured by _opts_.
|
1757
|
+
#
|
1758
|
+
# _opts_ can have the following keys:
|
1759
|
+
#
|
1760
|
+
# * *indent*: a string used to indent levels (default: ''),
|
1761
|
+
# * *space*: a string that is put after, a : or , delimiter (default: ''),
|
1762
|
+
# * *space_before*: a string that is put before a : pair delimiter (default: ''),
|
1763
|
+
# * *object_nl*: a string that is put at the end of a JSON object (default: ''),
|
1764
|
+
# * *array_nl*: a string that is put at the end of a JSON array (default: ''),
|
1765
|
+
# * *allow_nan*: true if NaN, Infinity, and -Infinity should be
|
1766
|
+
# generated, otherwise an exception is thrown, if these values are
|
1767
|
+
# encountered. This options defaults to false.
|
1768
|
+
# * *ascii_only*: true if only ASCII characters should be generated. This
|
1769
|
+
# option defaults to false.
|
1770
|
+
# * *buffer_initial_length*: sets the initial length of the generator's
|
1771
|
+
# internal buffer.
|
1772
|
+
#
|
1773
|
+
# @return [State] a new instance of State
|
1774
|
+
#
|
1775
|
+
# source://json//lib/json/ext/generator/state.rb#25
|
1776
|
+
def initialize(opts = T.unsafe(nil)); end
|
1777
|
+
|
1778
|
+
# call-seq: [](name)
|
1779
|
+
#
|
1780
|
+
# Returns the value returned by method +name+.
|
1781
|
+
#
|
1782
|
+
# source://json//lib/json/ext/generator/state.rb#94
|
1783
|
+
def [](name); end
|
1784
|
+
|
1785
|
+
# call-seq: []=(name, value)
|
1786
|
+
#
|
1787
|
+
# Sets the attribute name to value.
|
1788
|
+
#
|
1789
|
+
# source://json//lib/json/ext/generator/state.rb#106
|
1790
|
+
def []=(name, value); end
|
1791
|
+
|
1792
|
+
# call-seq: configure(opts)
|
1793
|
+
#
|
1794
|
+
# Configure this State instance with the Hash _opts_, and return
|
1795
|
+
# itself.
|
1796
|
+
#
|
1797
|
+
# source://json//lib/json/ext/generator/state.rb#35
|
1798
|
+
def configure(opts); end
|
1799
|
+
|
1800
|
+
# call-seq:
|
1801
|
+
# generate(obj) -> String
|
1802
|
+
# generate(obj, anIO) -> anIO
|
1803
|
+
#
|
1804
|
+
# Generates a valid JSON document from object +obj+ and returns the
|
1805
|
+
# result. If no valid JSON document can be created this method raises a
|
1806
|
+
# GeneratorError exception.
|
1807
|
+
#
|
1808
|
+
# source://json//lib/json/ext/generator/state.rb#57
|
1809
|
+
def generate(obj, io = T.unsafe(nil)); end
|
1810
|
+
|
1811
|
+
# call-seq: configure(opts)
|
1812
|
+
#
|
1813
|
+
# Configure this State instance with the Hash _opts_, and return
|
1814
|
+
# itself.
|
1815
|
+
#
|
1816
|
+
# source://json//lib/json/ext/generator/state.rb#35
|
1817
|
+
def merge(opts); end
|
1818
|
+
|
1819
|
+
# call-seq: to_h
|
1820
|
+
#
|
1821
|
+
# Returns the configuration instance variables as a hash, that can be
|
1822
|
+
# passed to the configure method.
|
1823
|
+
#
|
1824
|
+
# source://json//lib/json/ext/generator/state.rb#65
|
1825
|
+
def to_h; end
|
1826
|
+
|
1827
|
+
# call-seq: to_h
|
1828
|
+
#
|
1829
|
+
# Returns the configuration instance variables as a hash, that can be
|
1830
|
+
# passed to the configure method.
|
1831
|
+
#
|
1832
|
+
# source://json//lib/json/ext/generator/state.rb#65
|
1833
|
+
def to_hash; end
|
1834
|
+
end
|
1835
|
+
|
1836
|
+
# This exception is raised if a generator or unparser error occurs.
|
1837
|
+
#
|
1838
|
+
# source://json//lib/json/common.rb#146
|
1839
|
+
class JSON::GeneratorError < ::JSON::JSONError
|
1840
|
+
# @return [GeneratorError] a new instance of GeneratorError
|
1841
|
+
#
|
1842
|
+
# source://json//lib/json/common.rb#149
|
1843
|
+
def initialize(message, invalid_object = T.unsafe(nil)); end
|
1844
|
+
|
1845
|
+
# source://json//lib/json/common.rb#154
|
1846
|
+
def detailed_message(*_arg0, **_arg1, &_arg2); end
|
1468
1847
|
|
1469
|
-
#
|
1470
|
-
|
1848
|
+
# Returns the value of attribute invalid_object.
|
1849
|
+
#
|
1850
|
+
# source://json//lib/json/common.rb#147
|
1851
|
+
def invalid_object; end
|
1852
|
+
end
|
1471
1853
|
|
1472
1854
|
# source://json//lib/json/generic_object.rb#9
|
1473
1855
|
class JSON::GenericObject < ::OpenStruct
|
@@ -1512,29 +1894,29 @@ end
|
|
1512
1894
|
|
1513
1895
|
# The base exception for JSON errors.
|
1514
1896
|
#
|
1515
|
-
# source://json//lib/json/common.rb#
|
1897
|
+
# source://json//lib/json/common.rb#126
|
1516
1898
|
class JSON::JSONError < ::StandardError
|
1517
1899
|
class << self
|
1518
|
-
# source://json//lib/json/common.rb#
|
1900
|
+
# source://json//lib/json/common.rb#127
|
1519
1901
|
def wrap(exception); end
|
1520
1902
|
end
|
1521
1903
|
end
|
1522
1904
|
|
1523
|
-
# source://json//lib/json/common.rb#
|
1905
|
+
# source://json//lib/json/common.rb#8
|
1524
1906
|
JSON::NOT_SET = T.let(T.unsafe(nil), Object)
|
1525
1907
|
|
1526
|
-
# source://json//lib/json/common.rb#
|
1908
|
+
# source://json//lib/json/common.rb#43
|
1527
1909
|
JSON::Parser = JSON::Ext::Parser
|
1528
1910
|
|
1529
|
-
# source://json//lib/json/common.rb#
|
1911
|
+
# source://json//lib/json/common.rb#72
|
1530
1912
|
JSON::State = JSON::Ext::Generator::State
|
1531
1913
|
|
1532
1914
|
# For backwards compatibility
|
1533
1915
|
#
|
1534
|
-
# source://json//lib/json/common.rb#
|
1916
|
+
# source://json//lib/json/common.rb#164
|
1535
1917
|
JSON::UnparserError = JSON::GeneratorError
|
1536
1918
|
|
1537
|
-
# source://json//lib/json/common.rb#
|
1919
|
+
# source://json//lib/json/common.rb#846
|
1538
1920
|
module Kernel
|
1539
1921
|
private
|
1540
1922
|
|
@@ -1545,18 +1927,18 @@ module Kernel
|
|
1545
1927
|
# The _opts_ argument is passed through to generate/parse respectively. See
|
1546
1928
|
# generate and parse for their documentation.
|
1547
1929
|
#
|
1548
|
-
# source://json//lib/json/common.rb#
|
1930
|
+
# source://json//lib/json/common.rb#873
|
1549
1931
|
def JSON(object, *args); end
|
1550
1932
|
|
1551
1933
|
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
1552
1934
|
# one line.
|
1553
1935
|
#
|
1554
|
-
# source://json//lib/json/common.rb#
|
1936
|
+
# source://json//lib/json/common.rb#851
|
1555
1937
|
def j(*objs); end
|
1556
1938
|
|
1557
1939
|
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
1558
1940
|
# indentation and over many lines.
|
1559
1941
|
#
|
1560
|
-
# source://json//lib/json/common.rb#
|
1942
|
+
# source://json//lib/json/common.rb#860
|
1561
1943
|
def jj(*objs); end
|
1562
1944
|
end
|