diff --git a/Gemfile b/Gemfile
index 87727bb07..9f04c20f0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -32,7 +32,7 @@ group :development, :test do
gem "rails", "~> #{rails_version}.0"
# Remove this constraint once Rails ships a version that supports JSON 3
- gem "json", "< 3"
+ gem "json", "< 4"
end
gem "sqlite3"
diff --git a/Gemfile.lock b/Gemfile.lock
index d2b9c529d..0bc6a1f4b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -195,7 +195,7 @@ GEM
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
- json (2.21.2)
+ json (3.0.2)
kramdown (2.5.2)
rexml (>= 3.4.4)
kredis (1.8.0)
@@ -452,7 +452,7 @@ DEPENDENCIES
graphql
identity_cache
irb
- json (< 3)
+ json (< 4)
json_api_client!
kramdown (~> 2.5)
kredis
@@ -539,7 +539,7 @@ CHECKSUMS
identity_cache (1.6.5) sha256=cbac45390561ce59f399ae671019f350bb1e7090ae7ded4bbe5249de6691da2b
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
- json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
+ json (3.0.2) sha256=8e6d7e7b11384c21230430cef90b71f14849a34a1f4452796670f7c981bd19df
json_api_client (1.23.0)
kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa
kredis (1.8.0) sha256=34b72a0bc242d7aaea98e82b6a5a8c293a27e1b26f2c729a8d4e1e1409886150
diff --git a/sorbet/rbi/gems/json@3.0.2.rbi b/sorbet/rbi/gems/json@3.0.2.rbi
new file mode 100644
index 000000000..a37f4c685
--- /dev/null
+++ b/sorbet/rbi/gems/json@3.0.2.rbi
@@ -0,0 +1,1886 @@
+# typed: false
+
+# DO NOT EDIT MANUALLY
+# This is an autogenerated file for types exported from the `json` gem.
+# Please instead update this file by running `bin/tapioca gem json`.
+
+
+# = JavaScript \Object Notation (\JSON)
+#
+# \JSON is a lightweight data-interchange format.
+#
+# \JSON is easy for us humans to read and write,
+# and equally simple for machines to read (parse) and write (generate).
+#
+# \JSON is language-independent, making it an ideal interchange format
+# for applications in differing programming languages
+# and on differing operating systems.
+#
+# == \JSON Values
+#
+# A \JSON value is one of the following:
+# - Double-quoted text: "foo".
+# - Number: +1+, +1.0+, +2.0e2+.
+# - Boolean: +true+, +false+.
+# - Null: +null+.
+# - \Array: an ordered list of values, enclosed by square brackets:
+# ["foo", 1, 1.0, 2.0e2, true, false, null]
+#
+# - \Object: a collection of name/value pairs, enclosed by curly braces;
+# each name is double-quoted text;
+# the values may be any \JSON values:
+# {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
+#
+# A \JSON array or object may contain nested arrays, objects, and scalars
+# to any depth:
+# {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
+# [{"foo": 0, "bar": 1}, ["baz", 2]]
+#
+# == Using \Module \JSON
+#
+# To make module \JSON available in your code, begin with:
+# require 'json'
+#
+# All examples here assume that this has been done.
+#
+# === Parsing \JSON
+#
+# You can parse a \String containing \JSON data using
+# either of two methods:
+# - JSON.parse(source, **opts)
+# - JSON.parse!(source, **opts)
+#
+# where
+# - +source+ is a Ruby object.
+# - +opts+ are keyword arguments that control both input
+# allowed and output formatting.
+#
+# The difference between the two methods
+# is that JSON.parse! omits some checks
+# and may not be safe for some +source+ data;
+# use it only for data from trusted sources.
+# Use the safer method JSON.parse for less trusted sources.
+#
+# ==== Parsing \JSON Arrays
+#
+# When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:
+# json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
+# ruby = JSON.parse(json)
+# ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
+# ruby.class # => Array
+#
+# The \JSON array may contain nested arrays, objects, and scalars
+# to any depth:
+# json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
+# JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
+#
+# ==== Parsing \JSON \Objects
+#
+# When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:
+# json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
+# ruby = JSON.parse(json)
+# ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
+# ruby.class # => Hash
+#
+# The \JSON object may contain nested arrays, objects, and scalars
+# to any depth:
+# json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
+# JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
+#
+# ==== Parsing \JSON Scalars
+#
+# When the source is a \JSON scalar (not an array or object),
+# JSON.parse returns a Ruby scalar.
+#
+# \String:
+# ruby = JSON.parse('"foo"')
+# ruby # => 'foo'
+# ruby.class # => String
+# \Integer:
+# ruby = JSON.parse('1')
+# ruby # => 1
+# ruby.class # => Integer
+# \Float:
+# ruby = JSON.parse('1.0')
+# ruby # => 1.0
+# ruby.class # => Float
+# ruby = JSON.parse('2.0e2')
+# ruby # => 200.0
+# ruby.class # => Float
+# Boolean:
+# ruby = JSON.parse('true')
+# ruby # => true
+# ruby.class # => TrueClass
+# ruby = JSON.parse('false')
+# ruby # => false
+# ruby.class # => FalseClass
+# Null:
+# ruby = JSON.parse('null')
+# ruby # => nil
+# ruby.class # => NilClass
+#
+# ==== Parsing Options
+#
+# ====== Input Options
+#
+# Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed;
+# defaults to +100+;
+# You can set it to +false+ to disable depth checking entirely, but that is dangerous
+# when parsing untrusted input.
+#
+# With the default, +100+:
+# source = '[0, [1, [2, [3]]]]'
+# ruby = JSON.parse(source)
+# ruby # => [0, [1, [2, [3]]]]
+# Too deep:
+# # Raises JSON::NestingError (nesting of 2 is too deep):
+# JSON.parse(source, max_nesting: 1)
+# Bad value:
+# # Raises TypeError (no implicit conversion of Symbol into Integer):
+# JSON.parse(source, max_nesting: :foo)
+#
+# ---
+#
+# Option +allow_duplicate_key+ specifies whether duplicate keys in objects
+# should be ignored or cause an error to be raised:
+#
+# When set to +false+, the default:
+# JSON.parse('{"a": 1, "a": 2}') # duplicate key "a" at line 1 column 1 (JSON::ParserError)
+#
+# When set to +true+:
+# # The last value is used.
+# JSON.parse('{"a": 1, "a": 2}', allow_duplicate_key: true) # => {"a" => 2}
+#
+# ---
+#
+# Option +allow_nan+ (boolean) specifies whether to allow
+# NaN, Infinity, and MinusInfinity in +source+;
+# defaults to +false+.
+#
+# With the default, +false+:
+# # Raises JSON::ParserError (unexpected token 'NaN]' at line 1 column 2):
+# JSON.parse('[NaN]')
+# # Raises JSON::ParserError (unexpected token 'Infinity]' at line 1 column 2):
+# JSON.parse('[Infinity]')
+# # Raises JSON::ParserError (invalid number: '-Infinity]' at line 1 column 2):
+# JSON.parse('[-Infinity]')
+# Allow:
+# source = '[NaN, Infinity, -Infinity]'
+# ruby = JSON.parse(source, allow_nan: true)
+# ruby # => [NaN, Infinity, -Infinity]
+#
+# ---
+#
+# Option +allow_trailing_comma+ (boolean) specifies whether to allow
+# trailing commas in objects and arrays;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
+#
+# ---
+#
+# Option +allow_comments+ (boolean) specifies whether to allow
+# JavaScript style comments (either // comment or /* comment */);
+# defaults to +false+.
+#
+# When set to +false+, the default:
+# JSON.parse('/* comment */ {"a": 1, "a": 2}') # unexpected token '/*' at line 1 column 1 (JSON::ParserError)
+#
+# When set to +true+, comments are ignored:
+# JSON.parse('/* comment */ {"a": 1} // more comment', allow_comments: true) # => {"a" => 1}
+#
+# ---
+#
+# Option +allow_control_characters+ (boolean) specifies whether to allow
+# unescaped ASCII control characters, such as newlines, in strings;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string: \nWorld" at line 2 column 0 (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
+#
+# ---
+#
+# Option +allow_invalid_escape+ (boolean) specifies whether to ignore backslahes that are followed
+# by an invalid escape character in strings;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse('"Hell\o"') # invalid escape character in string: '\o"' at line 1 column 6 (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello"
+#
+# ====== Output Options
+#
+# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
+# defaults to +false+.
+#
+# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
+# should be Symbols;
+# defaults to +false+ (use Strings).
+#
+# With the default, +false+:
+# source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
+# ruby = JSON.parse(source)
+# ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
+# Use Symbols:
+# ruby = JSON.parse(source, symbolize_names: true)
+# ruby # => {a: "foo", b: 1.0, c: true, d: false, e: nil}
+#
+# ---
+#
+# Option +object_class+ (\Class) specifies the Ruby class to be used
+# for each \JSON object;
+# defaults to \Hash.
+#
+# With the default, \Hash:
+# source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
+# ruby = JSON.parse(source)
+# ruby.class # => Hash
+# Use class \OpenStruct:
+# ruby = JSON.parse(source, object_class: OpenStruct)
+# ruby # => #
+#
+# ---
+#
+# Option +array_class+ (\Class) specifies the Ruby class to be used
+# for each \JSON array;
+# defaults to \Array.
+#
+# With the default, \Array:
+# source = '["foo", 1.0, true, false, null]'
+# ruby = JSON.parse(source)
+# ruby.class # => Array
+# Use class \Set:
+# ruby = JSON.parse(source, array_class: Set)
+# ruby # => Set["foo", 1.0, true, false, nil]
+#
+# === Generating \JSON
+#
+# To generate a Ruby \String containing \JSON data,
+# use method JSON.generate(source, opts), where
+# - +source+ is a Ruby object.
+# - +opts+ is a \Hash object containing options
+# that control both input allowed and output formatting.
+#
+# ==== Generating \JSON from Arrays
+#
+# When the source is a Ruby \Array, JSON.generate returns
+# a \String containing a \JSON array:
+# ruby = [0, 's', :foo]
+# json = JSON.generate(ruby)
+# json # => '[0,"s","foo"]'
+#
+# The Ruby \Array array may contain nested arrays, hashes, and scalars
+# to any depth:
+# ruby = [0, [1, 2], {foo: 3, bar: 4}]
+# json = JSON.generate(ruby)
+# json # => '[0,[1,2],{"foo":3,"bar":4}]'
+#
+# ==== Generating \JSON from Hashes
+#
+# When the source is a Ruby \Hash, JSON.generate returns
+# a \String containing a \JSON object:
+# ruby = {foo: 0, bar: 's', baz: :bat}
+# json = JSON.generate(ruby)
+# json # => '{"foo":0,"bar":"s","baz":"bat"}'
+#
+# The Ruby \Hash array may contain nested arrays, hashes, and scalars
+# to any depth:
+# ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
+# json = JSON.generate(ruby)
+# json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
+#
+# ==== Generating \JSON from Other Objects
+#
+# When the source is neither an \Array nor a \Hash,
+# the generated \JSON data depends on the class of the source.
+#
+# When the source is a Ruby \Integer or \Float, JSON.generate returns
+# a \String containing a \JSON number:
+# JSON.generate(42) # => '42'
+# JSON.generate(0.42) # => '0.42'
+#
+# When the source is a Ruby \String, JSON.generate returns
+# a \String containing a \JSON string (with double-quotes):
+# JSON.generate('A string') # => '"A string"'
+#
+# When the source is +true+, +false+ or +nil+, JSON.generate returns
+# a \String containing the corresponding \JSON token:
+# JSON.generate(true) # => 'true'
+# JSON.generate(false) # => 'false'
+# JSON.generate(nil) # => 'null'
+#
+# When the source is none of the above, JSON.generate returns
+# a \String containing a \JSON string representation of the source:
+# JSON.generate(:foo) # => '"foo"'
+# JSON.generate(Complex(0, 0)) # => '"0+0i"'
+# JSON.generate(Dir.new('.')) # => '"#"'
+#
+# ==== Generating Options
+#
+# ====== Input Options
+#
+# Option +allow_nan+ (boolean) specifies whether
+# +NaN+, +Infinity+, and +-Infinity+ may be generated;
+# defaults to +false+.
+#
+# With the default, +false+:
+# # Raises JSON::GeneratorError (NaN not allowed in JSON):
+# JSON.generate(JSON::NaN)
+# # Raises JSON::GeneratorError (Infinity not allowed in JSON):
+# JSON.generate(JSON::Infinity)
+# # Raises JSON::GeneratorError (-Infinity not allowed in JSON):
+# JSON.generate(JSON::MinusInfinity)
+#
+# Allow:
+# ruby = [Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity]
+# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,NaN,Infinity,-Infinity]'
+#
+# ---
+#
+# Option +allow_duplicate_key+ (boolean) specifies whether
+# hashes with duplicate keys should be allowed or produce an error.
+# Defaults to +false+, which raises an error.
+#
+# With the default, +false+:
+# JSON.generate({foo: 1, "foo" => 2})
+# # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
+#
+# With +true+:
+# JSON.generate({foo: 1, "foo" => 2}, allow_duplicate_key: true)
+# # => '{"foo":1,"foo":2}'
+#
+# ---
+#
+# Option +max_nesting+ (\Integer) specifies the maximum nesting depth
+# in +obj+; defaults to +100+.
+#
+# With the default, +100+:
+# obj = [[[[[[0]]]]]]
+# JSON.generate(obj) # => '[[[[[[0]]]]]]'
+#
+# Too deep:
+# # Raises JSON::NestingError (nesting of 2 is too deep. Did you try to serialize objects with circular references?):
+# JSON.generate(obj, max_nesting: 2)
+#
+# With +false+:
+# obj = []
+# obj[0] = obj
+# # Raises SystemStackError (stack level too deep):
+# JSON.generate(obj, max_nesting: false)
+#
+# Setting +max_nesting+ to +false+ or a very large number can lead to a stack overflow
+# which may leave the process in an unrecoverable state.
+# It is highly discouraged.
+#
+# ====== Escaping Options
+#
+# Options +script_safe+ (boolean) specifies wether '\u2028', '\u2029'
+# and '/' should be escaped as to make the JSON object safe to interpolate in script
+# tags.
+#
+# Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
+# should be escaped.
+#
+# ====== Output Options
+#
+# The default formatting options generate the most compact
+# \JSON data, all on one line and with no whitespace.
+#
+# You can use these formatting options to generate
+# \JSON data in a more open format, using whitespace.
+# See also JSON.pretty_generate.
+#
+# - Option +array_nl+ (\String) specifies a string (usually a newline)
+# to be inserted after each \JSON array; defaults to the empty \String, ''.
+# - Option +object_nl+ (\String) specifies a string (usually a newline)
+# to be inserted after each \JSON object; defaults to the empty \String, ''.
+# - Option +indent+ (\String) specifies the string (usually spaces) to be
+# used for indentation; defaults to the empty \String, '';
+# has no effect unless options +array_nl+ or +object_nl+ specify newlines.
+# - Option +space+ (\String) specifies a string (usually a space) to be
+# inserted after the colon in each \JSON object's pair;
+# defaults to the empty \String, ''.
+# - Option +space_before+ (\String) specifies a string (usually a space) to be
+# inserted before the colon in each \JSON object's pair;
+# defaults to the empty \String, ''.
+# - Option +sort_keys+ (boolean or \Proc) controls whether and how the keys of a
+# hash are sorted when generating the output; defaults to +false+.
+# When +true+, keys are sorted lexicographically. When a \Proc, it receives
+# the entire \Hash and must return a \Hash with its pairs in the desired
+# order, allowing for arbitrary sort orders.
+#
+# In this example, +obj+ is used first to generate the shortest
+# \JSON data (no whitespace), then again with all formatting options
+# specified:
+#
+# obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
+# json = JSON.generate(obj)
+# puts 'Compact:', json
+# opts = {
+# array_nl: "\n",
+# object_nl: "\n",
+# indent: ' ',
+# space_before: ' ',
+# space: ' '
+# }
+# puts 'Open:', JSON.generate(obj, opts)
+#
+# Output:
+# Compact:
+# {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
+# Open:
+# {
+# "foo" : [
+# "bar",
+# "baz"
+# ],
+# "bat" : {
+# "bam" : 0,
+# "bad" : 1
+# }
+# }
+#
+# pkg:gem/json#lib/json/version.rb:3
+module JSON
+ private
+
+ # :call-seq:
+ # JSON.dump(obj, io = nil, _deprecated_limit = nil, options = nil)
+ #
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
+ #
+ # - Argument +io+, if given, should respond to method +write+;
+ # the \JSON \String is written to +io+, and +io+ is returned.
+ # If +io+ is not given, the \JSON \String is returned.
+ # - Argument +_deprecated_limit+ is deprecated, pass the +:max_nesting+ option instead.
+ # ---
+ #
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
+ # json = JSON.dump(obj)
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
+ #
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
+ # path = 't.json'
+ # File.open(path, 'w') do |file|
+ # JSON.dump(obj, file)
+ # end # => #
+ # puts File.read(path)
+ # Output:
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
+ #
+ # pkg:gem/json#lib/json/common.rb:752
+ def dump(obj, anIO = T.unsafe(nil), _deprecated_limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
+
+ # :call-seq:
+ # JSON.generate(obj, opts = nil) -> new_string
+ #
+ # Returns a \String containing the generated \JSON data.
+ #
+ # See also JSON.pretty_generate.
+ #
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
+ #
+ # ---
+ #
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
+ # obj = ["foo", 1.0, true, false, nil]
+ # json = JSON.generate(obj)
+ # json # => '["foo",1.0,true,false,null]'
+ #
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
+ # obj = {foo: 0, bar: 's', baz: :bat}
+ # json = JSON.generate(obj)
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
+ #
+ # For examples of generating from other Ruby objects, see
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
+ #
+ # ---
+ #
+ # Raises an exception if any formatting option is not a \String.
+ #
+ # Raises an exception if +obj+ contains circular references:
+ # a = []; b = []; a.push(b); b.push(a)
+ # # Raises JSON::NestingError (nesting of 100 is too deep. Did you try to serialize objects with circular references?):
+ # JSON.generate(a)
+ #
+ # pkg:gem/json#lib/json/common.rb:378
+ def generate(obj, opts = T.unsafe(nil)); end
+
+ # :call-seq:
+ # JSON.load(source, options = {}) -> object
+ # JSON.load(source, proc = nil, options = {}) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # - Argument +source+ must be, or be convertible to, a \String:
+ # - If +source+ responds to instance method +to_str+,
+ # source.to_str becomes the source.
+ # - If +source+ responds to instance method +to_io+,
+ # source.to_io.read becomes the source.
+ # - If +source+ responds to instance method +read+,
+ # source.read becomes the source.
+ # - If both of the following are true, source becomes the \String 'null':
+ # - Option +allow_blank+ specifies a truthy value.
+ # - The source, as defined above, is +nil+ or the empty \String ''.
+ # - Otherwise, +source+ remains the source.
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
+ # It will be called recursively with each result (depth-first order).
+ # See details below.
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
+ # parse(source, opts); see #parse.
+ #
+ # Source for following examples:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ #
+ # Load a \String:
+ # ruby = JSON.load(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load an \IO object:
+ # require 'stringio'
+ # object = JSON.load(StringIO.new(source))
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load a \File object:
+ # path = 't.json'
+ # File.write(path, source)
+ # File.open(path) do |file|
+ # JSON.load(file)
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # When +proc+ is given:
+ # - Modifies +source+ as above.
+ # - Gets the +result+ from calling parse(source, opts).
+ # - Recursively calls proc(result).
+ # - Returns the final result.
+ #
+ # Example:
+ # require 'json'
+ #
+ # # Some classes for the example.
+ # class Base
+ # def initialize(attributes)
+ # @attributes = attributes
+ # end
+ # end
+ # class User < Base; end
+ # class Account < Base; end
+ # class Admin < Base; end
+ # # The JSON source.
+ # json = <<-EOF
+ # {
+ # "users": [
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
+ # {"type": "User", "username": "john", "email": "john@example.com"}
+ # ],
+ # "accounts": [
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
+ # ],
+ # "admins": {"type": "Admin", "password": "0wn3d"}
+ # }
+ # EOF
+ # # Deserializer method.
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
+ # type = obj.is_a?(Hash) && obj["type"]
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
+ # end
+ # # Call to JSON.load
+ # ruby = JSON.load(json, proc {|obj|
+ # case obj
+ # when Hash
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
+ # when Array
+ # obj.map! {|v| deserialize_obj v }
+ # end
+ # obj
+ # })
+ # pp ruby
+ # Output:
+ # {"users"=>
+ # [#"User", "username"=>"jane", "email"=>"jane@example.com"}>,
+ # #"User", "username"=>"john", "email"=>"john@example.com"}>],
+ # "accounts"=>
+ # [{"account"=>
+ # #"Account", "paid"=>true, "account_id"=>"1234"}>},
+ # {"account"=>
+ # #"Account", "paid"=>false, "account_id"=>"1235"}>}],
+ # "admins"=>
+ # #"Admin", "password"=>"0wn3d"}>}
+ #
+ # pkg:gem/json#lib/json/common.rb:706
+ def load(source, proc = T.unsafe(nil), allow_blank: T.unsafe(nil), **options); end
+
+ # :call-seq:
+ # JSON.load_file(path, **) -> object
+ #
+ # Calls:
+ # parse(File.read(path), **)
+ #
+ # See method #parse.
+ #
+ # pkg:gem/json#lib/json/common.rb:327
+ def load_file(filespec, **options); end
+
+ # :call-seq:
+ # JSON.load_file!(path, **)
+ #
+ # Calls:
+ # JSON.parse!(File.read(path), **)
+ #
+ # See method #parse!
+ #
+ # pkg:gem/json#lib/json/common.rb:338
+ def load_file!(filespec, **options); end
+
+ # :call-seq:
+ # JSON.parse(source, opts) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # Argument +source+ contains the \String to be parsed.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When +source+ is a \JSON array, returns a Ruby \Array:
+ # source = '["foo", 1.0, true, false, null]'
+ # ruby = JSON.parse(source)
+ # ruby # => ["foo", 1.0, true, false, nil]
+ # ruby.class # => Array
+ #
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
+ # ruby = JSON.parse(source)
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
+ # ruby.class # => Hash
+ #
+ # For examples of parsing for all \JSON data types, see
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
+ #
+ # Parses nested JSON objects:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ # ruby = JSON.parse(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # Raises an exception if +source+ is not valid JSON:
+ # # Raises JSON::ParserError (unexpected character: 'invalid' at line 1 column 1):
+ # JSON.parse('invalid')
+ #
+ # pkg:gem/json#lib/json/common.rb:296
+ def parse(source, on_load: T.unsafe(nil), object_class: T.unsafe(nil), array_class: T.unsafe(nil), **options); end
+
+ # :call-seq:
+ # JSON.parse!(source, opts) -> object
+ #
+ # Calls
+ # parse(source, opts)
+ # with +source+ and possibly modified +opts+.
+ #
+ # Differences from JSON.parse:
+ # - Option +max_nesting+, if not provided, defaults to +false+,
+ # which disables checking for nesting depth.
+ # - Option +allow_nan+, if not provided, defaults to +true+.
+ #
+ # pkg:gem/json#lib/json/common.rb:316
+ def parse!(source, **options); end
+
+ # :call-seq:
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
+ #
+ # Arguments +obj+ and +opts+ here are the same as
+ # arguments +obj+ and +opts+ in JSON.generate.
+ #
+ # Default options are:
+ # {
+ # indent: ' ', # Two spaces
+ # space: ' ', # One space
+ # array_nl: "\n", # Newline
+ # object_nl: "\n" # Newline
+ # }
+ #
+ # Example:
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
+ # json = JSON.pretty_generate(obj)
+ # puts json
+ # Output:
+ # {
+ # "foo": [
+ # "bar",
+ # "baz"
+ # ],
+ # "bat": {
+ # "bam": 0,
+ # "bad": 1
+ # }
+ # }
+ #
+ # pkg:gem/json#lib/json/common.rb:424
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
+
+ # :call-seq:
+ # JSON.unsafe_load(source, options = {}) -> object
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # BEWARE: This method is meant to deserialise data from trusted user input,
+ # like from your own database server or clients under your control, it could
+ # be dangerous to allow untrusted users to pass JSON sources into it.
+ #
+ # - Argument +source+ must be, or be convertible to, a \String:
+ # - If +source+ responds to instance method +to_str+,
+ # source.to_str becomes the source.
+ # - If +source+ responds to instance method +to_io+,
+ # source.to_io.read becomes the source.
+ # - If +source+ responds to instance method +read+,
+ # source.read becomes the source.
+ # - If both of the following are true, source becomes the \String 'null':
+ # - Option +allow_blank+ specifies a truthy value.
+ # - The source, as defined above, is +nil+ or the empty \String ''.
+ # - Otherwise, +source+ remains the source.
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
+ # It will be called recursively with each result (depth-first order).
+ # See details below.
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
+ # parse(source, opts); see #parse.
+ #
+ # Source for following examples:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ #
+ # Load a \String:
+ # ruby = JSON.unsafe_load(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load an \IO object:
+ # require 'stringio'
+ # object = JSON.unsafe_load(StringIO.new(source))
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load a \File object:
+ # path = 't.json'
+ # File.write(path, source)
+ # File.open(path) do |file|
+ # JSON.unsafe_load(file)
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # When +proc+ is given:
+ # - Modifies +source+ as above.
+ # - Gets the +result+ from calling parse(source, opts).
+ # - Recursively calls proc(result).
+ # - Returns the final result.
+ #
+ # Example:
+ # require 'json'
+ #
+ # # Some classes for the example.
+ # class Base
+ # def initialize(attributes)
+ # @attributes = attributes
+ # end
+ # end
+ # class User < Base; end
+ # class Account < Base; end
+ # class Admin < Base; end
+ # # The JSON source.
+ # json = <<-EOF
+ # {
+ # "users": [
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
+ # {"type": "User", "username": "john", "email": "john@example.com"}
+ # ],
+ # "accounts": [
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
+ # ],
+ # "admins": {"type": "Admin", "password": "0wn3d"}
+ # }
+ # EOF
+ # # Deserializer method.
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
+ # type = obj.is_a?(Hash) && obj["type"]
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
+ # end
+ # # Call to JSON.unsafe_load
+ # ruby = JSON.unsafe_load(json, proc {|obj|
+ # case obj
+ # when Hash
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
+ # when Array
+ # obj.map! {|v| deserialize_obj v }
+ # end
+ # obj
+ # })
+ # pp ruby
+ # Output:
+ # {"users"=>
+ # [#"User", "username"=>"jane", "email"=>"jane@example.com"}>,
+ # #"User", "username"=>"john", "email"=>"john@example.com"}>],
+ # "accounts"=>
+ # [{"account"=>
+ # #"Account", "paid"=>true, "account_id"=>"1234"}>},
+ # {"account"=>
+ # #"Account", "paid"=>false, "account_id"=>"1235"}>}],
+ # "admins"=>
+ # #"Admin", "password"=>"0wn3d"}>}
+ #
+ # pkg:gem/json#lib/json/common.rb:576
+ def unsafe_load(source, proc = T.unsafe(nil), **options); end
+
+ class << self
+ # :call-seq:
+ # JSON[object] -> new_array or new_string
+ #
+ # If +object+ is a \String,
+ # calls JSON.parse with +object+ and +opts+ (see method #parse):
+ # json = '[0, 1, null]'
+ # JSON[json]# => [0, 1, nil]
+ #
+ # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
+ # ruby = [0, 1, nil]
+ # JSON[ruby] # => '[0,1,null]'
+ #
+ # pkg:gem/json#lib/json/common.rb:54
+ def [](object, opts = T.unsafe(nil)); end
+
+ # :call-seq:
+ # JSON.dump(obj, io = nil, _deprecated_limit = nil, options = nil)
+ #
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
+ #
+ # - Argument +io+, if given, should respond to method +write+;
+ # the \JSON \String is written to +io+, and +io+ is returned.
+ # If +io+ is not given, the \JSON \String is returned.
+ # - Argument +_deprecated_limit+ is deprecated, pass the +:max_nesting+ option instead.
+ # ---
+ #
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
+ # json = JSON.dump(obj)
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
+ #
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
+ # path = 't.json'
+ # File.open(path, 'w') do |file|
+ # JSON.dump(obj, file)
+ # end # => #
+ # puts File.read(path)
+ # Output:
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
+ #
+ # pkg:gem/json#lib/json/common.rb:752
+ def dump(obj, anIO = T.unsafe(nil), _deprecated_limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
+
+ # :call-seq:
+ # JSON.generate(obj, opts = nil) -> new_string
+ #
+ # Returns a \String containing the generated \JSON data.
+ #
+ # See also JSON.pretty_generate.
+ #
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
+ #
+ # ---
+ #
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
+ # obj = ["foo", 1.0, true, false, nil]
+ # json = JSON.generate(obj)
+ # json # => '["foo",1.0,true,false,null]'
+ #
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
+ # obj = {foo: 0, bar: 's', baz: :bat}
+ # json = JSON.generate(obj)
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
+ #
+ # For examples of generating from other Ruby objects, see
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
+ #
+ # ---
+ #
+ # Raises an exception if any formatting option is not a \String.
+ #
+ # Raises an exception if +obj+ contains circular references:
+ # a = []; b = []; a.push(b); b.push(a)
+ # # Raises JSON::NestingError (nesting of 100 is too deep. Did you try to serialize objects with circular references?):
+ # JSON.generate(a)
+ #
+ # pkg:gem/json#lib/json/common.rb:378
+ def generate(obj, opts = T.unsafe(nil)); end
+
+ # Returns the JSON generator module that is used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:112
+ def generator; end
+
+ # Set the module _generator_ to be used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:80
+ def generator=(generator); end
+
+ # :call-seq:
+ # JSON.load(source, options = {}) -> object
+ # JSON.load(source, proc = nil, options = {}) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # - Argument +source+ must be, or be convertible to, a \String:
+ # - If +source+ responds to instance method +to_str+,
+ # source.to_str becomes the source.
+ # - If +source+ responds to instance method +to_io+,
+ # source.to_io.read becomes the source.
+ # - If +source+ responds to instance method +read+,
+ # source.read becomes the source.
+ # - If both of the following are true, source becomes the \String 'null':
+ # - Option +allow_blank+ specifies a truthy value.
+ # - The source, as defined above, is +nil+ or the empty \String ''.
+ # - Otherwise, +source+ remains the source.
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
+ # It will be called recursively with each result (depth-first order).
+ # See details below.
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
+ # parse(source, opts); see #parse.
+ #
+ # Source for following examples:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ #
+ # Load a \String:
+ # ruby = JSON.load(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load an \IO object:
+ # require 'stringio'
+ # object = JSON.load(StringIO.new(source))
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load a \File object:
+ # path = 't.json'
+ # File.write(path, source)
+ # File.open(path) do |file|
+ # JSON.load(file)
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # When +proc+ is given:
+ # - Modifies +source+ as above.
+ # - Gets the +result+ from calling parse(source, opts).
+ # - Recursively calls proc(result).
+ # - Returns the final result.
+ #
+ # Example:
+ # require 'json'
+ #
+ # # Some classes for the example.
+ # class Base
+ # def initialize(attributes)
+ # @attributes = attributes
+ # end
+ # end
+ # class User < Base; end
+ # class Account < Base; end
+ # class Admin < Base; end
+ # # The JSON source.
+ # json = <<-EOF
+ # {
+ # "users": [
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
+ # {"type": "User", "username": "john", "email": "john@example.com"}
+ # ],
+ # "accounts": [
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
+ # ],
+ # "admins": {"type": "Admin", "password": "0wn3d"}
+ # }
+ # EOF
+ # # Deserializer method.
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
+ # type = obj.is_a?(Hash) && obj["type"]
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
+ # end
+ # # Call to JSON.load
+ # ruby = JSON.load(json, proc {|obj|
+ # case obj
+ # when Hash
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
+ # when Array
+ # obj.map! {|v| deserialize_obj v }
+ # end
+ # obj
+ # })
+ # pp ruby
+ # Output:
+ # {"users"=>
+ # [#"User", "username"=>"jane", "email"=>"jane@example.com"}>,
+ # #"User", "username"=>"john", "email"=>"john@example.com"}>],
+ # "accounts"=>
+ # [{"account"=>
+ # #"Account", "paid"=>true, "account_id"=>"1234"}>},
+ # {"account"=>
+ # #"Account", "paid"=>false, "account_id"=>"1235"}>}],
+ # "admins"=>
+ # #"Admin", "password"=>"0wn3d"}>}
+ #
+ # pkg:gem/json#lib/json/common.rb:706
+ def load(source, proc = T.unsafe(nil), allow_blank: T.unsafe(nil), **options); end
+
+ # :call-seq:
+ # JSON.load_file(path, **) -> object
+ #
+ # Calls:
+ # parse(File.read(path), **)
+ #
+ # See method #parse.
+ #
+ # pkg:gem/json#lib/json/common.rb:327
+ def load_file(filespec, **options); end
+
+ # :call-seq:
+ # JSON.load_file!(path, **)
+ #
+ # Calls:
+ # JSON.parse!(File.read(path), **)
+ #
+ # See method #parse!
+ #
+ # pkg:gem/json#lib/json/common.rb:338
+ def load_file!(filespec, **options); end
+
+ # :call-seq:
+ # JSON.parse(source, opts) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # Argument +source+ contains the \String to be parsed.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When +source+ is a \JSON array, returns a Ruby \Array:
+ # source = '["foo", 1.0, true, false, null]'
+ # ruby = JSON.parse(source)
+ # ruby # => ["foo", 1.0, true, false, nil]
+ # ruby.class # => Array
+ #
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
+ # ruby = JSON.parse(source)
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
+ # ruby.class # => Hash
+ #
+ # For examples of parsing for all \JSON data types, see
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
+ #
+ # Parses nested JSON objects:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ # ruby = JSON.parse(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # Raises an exception if +source+ is not valid JSON:
+ # # Raises JSON::ParserError (unexpected character: 'invalid' at line 1 column 1):
+ # JSON.parse('invalid')
+ #
+ # pkg:gem/json#lib/json/common.rb:296
+ def parse(source, on_load: T.unsafe(nil), object_class: T.unsafe(nil), array_class: T.unsafe(nil), **options); end
+
+ # :call-seq:
+ # JSON.parse!(source, opts) -> object
+ #
+ # Calls
+ # parse(source, opts)
+ # with +source+ and possibly modified +opts+.
+ #
+ # Differences from JSON.parse:
+ # - Option +max_nesting+, if not provided, defaults to +false+,
+ # which disables checking for nesting depth.
+ # - Option +allow_nan+, if not provided, defaults to +true+.
+ #
+ # pkg:gem/json#lib/json/common.rb:316
+ def parse!(source, **options); end
+
+ # Returns the JSON parser class that is used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:70
+ def parser; end
+
+ # Set the JSON parser class _parser_ to be used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:73
+ def parser=(parser); end
+
+ # :call-seq:
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
+ #
+ # Arguments +obj+ and +opts+ here are the same as
+ # arguments +obj+ and +opts+ in JSON.generate.
+ #
+ # Default options are:
+ # {
+ # indent: ' ', # Two spaces
+ # space: ' ', # One space
+ # array_nl: "\n", # Newline
+ # object_nl: "\n" # Newline
+ # }
+ #
+ # Example:
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
+ # json = JSON.pretty_generate(obj)
+ # puts json
+ # Output:
+ # {
+ # "foo": [
+ # "bar",
+ # "baz"
+ # ],
+ # "bat": {
+ # "bam": 0,
+ # "bad": 1
+ # }
+ # }
+ #
+ # pkg:gem/json#lib/json/common.rb:424
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
+
+ # Sets or Returns the JSON generator state class that is used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:115
+ def state; end
+
+ # Sets or Returns the JSON generator state class that is used by JSON.
+ #
+ # pkg:gem/json#lib/json/common.rb:115
+ def state=(_arg0); end
+
+ # :call-seq:
+ # JSON.unsafe_load(source, options = {}) -> object
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # BEWARE: This method is meant to deserialise data from trusted user input,
+ # like from your own database server or clients under your control, it could
+ # be dangerous to allow untrusted users to pass JSON sources into it.
+ #
+ # - Argument +source+ must be, or be convertible to, a \String:
+ # - If +source+ responds to instance method +to_str+,
+ # source.to_str becomes the source.
+ # - If +source+ responds to instance method +to_io+,
+ # source.to_io.read becomes the source.
+ # - If +source+ responds to instance method +read+,
+ # source.read becomes the source.
+ # - If both of the following are true, source becomes the \String 'null':
+ # - Option +allow_blank+ specifies a truthy value.
+ # - The source, as defined above, is +nil+ or the empty \String ''.
+ # - Otherwise, +source+ remains the source.
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
+ # It will be called recursively with each result (depth-first order).
+ # See details below.
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ #
+ # ---
+ #
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
+ # parse(source, opts); see #parse.
+ #
+ # Source for following examples:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ #
+ # Load a \String:
+ # ruby = JSON.unsafe_load(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load an \IO object:
+ # require 'stringio'
+ # object = JSON.unsafe_load(StringIO.new(source))
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load a \File object:
+ # path = 't.json'
+ # File.write(path, source)
+ # File.open(path) do |file|
+ # JSON.unsafe_load(file)
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # When +proc+ is given:
+ # - Modifies +source+ as above.
+ # - Gets the +result+ from calling parse(source, opts).
+ # - Recursively calls proc(result).
+ # - Returns the final result.
+ #
+ # Example:
+ # require 'json'
+ #
+ # # Some classes for the example.
+ # class Base
+ # def initialize(attributes)
+ # @attributes = attributes
+ # end
+ # end
+ # class User < Base; end
+ # class Account < Base; end
+ # class Admin < Base; end
+ # # The JSON source.
+ # json = <<-EOF
+ # {
+ # "users": [
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
+ # {"type": "User", "username": "john", "email": "john@example.com"}
+ # ],
+ # "accounts": [
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
+ # ],
+ # "admins": {"type": "Admin", "password": "0wn3d"}
+ # }
+ # EOF
+ # # Deserializer method.
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
+ # type = obj.is_a?(Hash) && obj["type"]
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
+ # end
+ # # Call to JSON.unsafe_load
+ # ruby = JSON.unsafe_load(json, proc {|obj|
+ # case obj
+ # when Hash
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
+ # when Array
+ # obj.map! {|v| deserialize_obj v }
+ # end
+ # obj
+ # })
+ # pp ruby
+ # Output:
+ # {"users"=>
+ # [#"User", "username"=>"jane", "email"=>"jane@example.com"}>,
+ # #"User", "username"=>"john", "email"=>"john@example.com"}>],
+ # "accounts"=>
+ # [{"account"=>
+ # #"Account", "paid"=>true, "account_id"=>"1234"}>},
+ # {"account"=>
+ # #"Account", "paid"=>false, "account_id"=>"1235"}>}],
+ # "admins"=>
+ # #"Admin", "password"=>"0wn3d"}>}
+ #
+ # pkg:gem/json#lib/json/common.rb:576
+ def unsafe_load(source, proc = T.unsafe(nil), **options); end
+
+ private
+
+ # Called from the extension when a hash has both string and symbol keys
+ #
+ # pkg:gem/json#lib/json/common.rb:120
+ def on_mixed_keys_hash(hash); end
+ end
+end
+
+# JSON::Coder holds a parser and generator configuration.
+#
+# module MyApp
+# JSONC_CODER = JSON::Coder.new(
+# allow_trailing_comma: true
+# )
+# end
+#
+# MyApp::JSONC_CODER.load(document)
+#
+# pkg:gem/json#lib/json/common.rb:792
+class JSON::Coder
+ # :call-seq:
+ # JSON::Coder.new(**options, &block)
+ #
+ # Keyword arguments +options+, if given, are options for both parsing and generating.
+ # See {Parsing Options}[rdoc-ref:JSON@Parsing+Options],
+ # and {Generating Options}[rdoc-ref:JSON@Generating+Options].
+ #
+ # For generation, the strict: true option is always set. When a Ruby object with no native \JSON counterpart is
+ # encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
+ # \JSON counterpart:
+ #
+ # module MyApp
+ # API_JSON_CODER = JSON::Coder.new do |object|
+ # case object
+ # when Time
+ # object.iso8601(3)
+ # else
+ # object # Unknown type, will raise
+ # end
+ # end
+ # end
+ #
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
+ #
+ # pkg:gem/json#lib/json/common.rb:838
+ def initialize(object_class: T.unsafe(nil), array_class: T.unsafe(nil), on_load: T.unsafe(nil), **options, &as_json); end
+
+ # call-seq:
+ # dump(object) -> String
+ # dump(object, io) -> io
+ #
+ # Serialize the given object into a \JSON document.
+ #
+ # pkg:gem/json#lib/json/common.rb:859
+ def dump(object, io = T.unsafe(nil)); end
+
+ # pkg:gem/json#lib/json/common.rb:862
+ def generate(object, io = T.unsafe(nil)); end
+
+ # call-seq:
+ # load(string) -> Object
+ #
+ # Parse the given \JSON document and return an equivalent Ruby object.
+ #
+ # pkg:gem/json#lib/json/common.rb:868
+ def load(source); end
+
+ # call-seq:
+ # load(path) -> Object
+ #
+ # Parse the given \JSON document and return an equivalent Ruby object.
+ #
+ # pkg:gem/json#lib/json/common.rb:877
+ def load_file(path); end
+
+ # pkg:gem/json#lib/json/common.rb:871
+ def parse(source); end
+end
+
+# pkg:gem/json#lib/json/common.rb:807
+JSON::Coder::EXCLUDED_GENERATOR_OPTIONS = T.let(T.unsafe(nil), Array)
+
+# pkg:gem/json#lib/json/common.rb:793
+JSON::Coder::PARSER_OPTIONS = T.let(T.unsafe(nil), Array)
+
+# pkg:gem/json#lib/json/ext.rb:39
+class JSON::Ext::Generator::State
+ # call-seq: new(opts = {})
+ #
+ # Instantiates a new State object, configured by _opts_.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
+ # See {Generating Options}[rdoc-ref:JSON@Generating+Options].
+ #
+ # pkg:gem/json#lib/json/ext.rb:39
+ def initialize(opts = T.unsafe(nil)); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def _generate_no_fallback(*_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def allow_nan=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def allow_nan?; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def array_nl; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def array_nl=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def as_json; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def as_json=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def ascii_only=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def ascii_only?; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def buffer_initial_length; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def buffer_initial_length=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def check_circular?; end
+
+ # call-seq: configure(opts)
+ #
+ # Configure this State instance with the Hash _opts_, and return
+ # itself.
+ #
+ # pkg:gem/json#lib/json/ext/generator/state.rb:23
+ def configure(opts); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def depth; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def depth=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def generate(*_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def indent; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def indent=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def max_nesting; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def max_nesting=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext/generator/state.rb:36
+ def merge(opts); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def object_nl; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def object_nl=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def script_safe; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def script_safe=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def script_safe?; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def sort_keys; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def sort_keys=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def space; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def space=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def space_before; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def space_before=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def strict; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def strict=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def strict?; end
+
+ # call-seq: to_h
+ #
+ # Returns the configuration instance variables as a hash, that can be
+ # passed to the configure method.
+ #
+ # pkg:gem/json#lib/json/ext/generator/state.rb:42
+ def to_h; end
+
+ # pkg:gem/json#lib/json/ext/generator/state.rb:73
+ def to_hash; end
+
+ private
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def _configure(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def allow_duplicate_key?; end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def initialize_copy(_arg0); end
+
+ class << self
+ # pkg:gem/json#lib/json/ext.rb:39
+ def _generate_no_fallback(_arg0, _arg1, _arg2); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def default_sort_keys_proc=(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def from_state(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:39
+ def generate(_arg0, _arg1, _arg2); end
+ end
+end
+
+# pkg:gem/json#lib/json/ext.rb:9
+class JSON::Ext::Parser
+ # pkg:gem/json#lib/json/ext.rb:17
+ def initialize(source, opts = T.unsafe(nil)); end
+
+ # pkg:gem/json#lib/json/ext.rb:26
+ def parse; end
+
+ # pkg:gem/json#lib/json/ext.rb:22
+ def source; end
+
+ class << self
+ # pkg:gem/json#lib/json/ext.rb:11
+ def parse(_arg0, _arg1); end
+ end
+end
+
+# pkg:gem/json#lib/json/ext.rb:32
+JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
+
+# pkg:gem/json#lib/json/ext.rb:31
+class JSON::Ext::ParserConfig
+ # pkg:gem/json#lib/json/ext.rb:31
+ def initialize(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def parse(_arg0); end
+end
+
+# Fragment of JSON document that is to be included as is:
+# fragment = JSON::Fragment.new("[1, 2, 3]")
+# JSON.generate({ count: 3, items: fragments })
+#
+# This allows to easily assemble multiple JSON fragments that have
+# been persisted somewhere without having to parse them nor resorting
+# to string interpolation.
+#
+# Note: no validation is performed on the provided string. It is the
+# responsibility of the caller to ensure the string contains valid JSON.
+#
+# pkg:gem/json#lib/json/common.rb:232
+class JSON::Fragment < ::Struct
+ # pkg:gem/json#lib/json/common.rb:233
+ def initialize(json); end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def json; end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def json=(_); end
+
+ # pkg:gem/json#lib/json/common.rb:241
+ def to_json(state = T.unsafe(nil), *); end
+
+ class << self
+ # pkg:gem/json#lib/json/common.rb:232
+ def [](*_arg0); end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def inspect; end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def keyword_init?; end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def members; end
+
+ # pkg:gem/json#lib/json/common.rb:232
+ def new(*_arg0); end
+ end
+end
+
+# This exception is raised if a generator or unparser error occurs.
+#
+# pkg:gem/json#lib/json/common.rb:202
+class JSON::GeneratorError < ::JSON::JSONError
+ # pkg:gem/json#lib/json/common.rb:205
+ def initialize(message, invalid_object = T.unsafe(nil)); end
+
+ # pkg:gem/json#lib/json/common.rb:210
+ def detailed_message(*, **, &); end
+
+ # pkg:gem/json#lib/json/common.rb:203
+ def invalid_object; end
+end
+
+# pkg:gem/json#lib/json/common.rb:882
+module JSON::GeneratorMethods
+ # call-seq: to_json(*)
+ #
+ # Converts this object into a JSON string.
+ # If this object doesn't directly maps to a JSON native type,
+ # first convert it to a string (calling #to_s), then converts
+ # it to a JSON string, and returns the result.
+ # This is a fallback, if no special method #to_json was defined for some object.
+ #
+ # pkg:gem/json#lib/json/common.rb:890
+ def to_json(state = T.unsafe(nil), *); end
+end
+
+# pkg:gem/json#lib/json/common.rb:386
+JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
+
+# pkg:gem/json#lib/json/common.rb:76
+JSON::Parser = JSON::Ext::Parser
+
+# This exception is raised if a parser error occurs.
+#
+# pkg:gem/json#lib/json/common.rb:144
+class JSON::ParserError < ::JSON::JSONError
+ # Column number where the parser encountered an error.
+ # Is +nil+ when raised by JSON::ResumableParser.
+ #
+ # pkg:gem/json#lib/json/common.rb:151
+ def column; end
+
+ # Returns a best effort JSONPath string representing where in the document
+ # the parser encountered an error:
+ #
+ # begin
+ # JSON.parse('{"articles": [ { "title": invalid } ]}')
+ # rescue JSON::ParserError => error
+ # error.json_path # => "$.articles[0].title"
+ # end
+ #
+ # pkg:gem/json#lib/json/common.rb:161
+ def json_path; end
+
+ # Line number where the parser encountered an error.
+ # Is +nil+ when raised by JSON::ResumableParser.
+ #
+ # pkg:gem/json#lib/json/common.rb:147
+ def line; end
+
+ private
+
+ # pkg:gem/json#lib/json/common.rb:173
+ def build_json_path(segments); end
+end
+
+# pkg:gem/json#lib/json/common.rb:6
+module JSON::ParserOptions
+ class << self
+ # pkg:gem/json#lib/json/common.rb:8
+ def on_load(on_load, object_class, array_class); end
+
+ private
+
+ # pkg:gem/json#lib/json/common.rb:27
+ def array_class_proc(array_class, on_load); end
+
+ # pkg:gem/json#lib/json/common.rb:16
+ def object_class_proc(object_class, on_load); end
+ end
+end
+
+# Not yet available on JRuby
+#
+# pkg:gem/json#lib/json/ext.rb:31
+class JSON::ResumableParser
+ # pkg:gem/json#lib/json/ext.rb:31
+ def initialize(*_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def <<(_arg0); end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def clear; end
+
+ # Returns whether the parser is entirely done: no unconsumed bytes in
+ # the buffer, no document under construction and no parsed value
+ # awaiting retrieval.
+ #
+ # The main use case is detecting a truncated stream once the input is
+ # exhausted:
+ #
+ # loop do
+ # begin
+ # parser << socket.readpartial(4096)
+ # rescue EOFError
+ # break
+ # end
+ # while parser.parse
+ # process(parser.value)
+ # end
+ # end
+ # warn "stream was truncated" unless parser.empty?
+ #
+ # pkg:gem/json#lib/json/ext.rb:64
+ def empty?; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def eos?; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def parse; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def parsed_bytes; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def partial_value; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def partial_value?; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def rest; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def value; end
+
+ # pkg:gem/json#lib/json/ext.rb:31
+ def value?; end
+end
+
+# pkg:gem/json#lib/json/common.rb:106
+JSON::State = JSON::Ext::Generator::State
+
+# pkg:gem/json#lib/json/common.rb:907
+module Kernel
+ private
+
+ # If _object_ is string-like, parse the string and return the parsed result as
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
+ # structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively. See
+ # generate and parse for their documentation.
+ #
+ # pkg:gem/json#lib/json/common.rb:916
+ def JSON(object, opts = T.unsafe(nil)); end
+end
+
+# pkg:gem/json#lib/json/common.rb:921
+class Object < ::BasicObject
+ include ::Kernel
+ include ::PP::ObjectMixin
+ include ::JSON::GeneratorMethods
+end