Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial compliance with doc/method_documentation.rdoc #446

Merged
merged 1 commit into from Aug 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 7 additions & 17 deletions lib/json/common.rb
Expand Up @@ -7,8 +7,7 @@ class << self
# :call-seq:
# JSON[object] -> new_array or new_string
#
# If +object+ is a
# {String-convertible object}[doc/implicit_conversion_rdoc.html#label-String-Convertible+Objects],
# If +object+ is a \String,
# calls JSON.parse with +object+ and +opts+ (see method #parse):
# json = '[0, 1, null]'
# JSON[json]# => [0, 1, nil]
Expand Down Expand Up @@ -149,12 +148,9 @@ class MissingUnicodeSupport < JSONError; end
#
# Returns the Ruby objects created by parsing the given +source+.
#
# Argument +source+ contains the \String to be parsed. It must be a
# {String-convertible object}[doc/implicit_conversion_rdoc.html#label-String-Convertible+Objects]
# (implementing +to_str+), and must contain valid \JSON data.
# Argument +source+ contains the \String to be parsed.
#
# Argument +opts+, if given, contains options for the parsing, and must be a
# {Hash-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash+Convertible+Objects].
# Argument +opts+, if given, contains a \Hash of options for the parsing.
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
#
# ---
Expand Down Expand Up @@ -249,22 +245,17 @@ def load_file!(filespec, opts = {})
#
# Argument +obj+ is the Ruby object to be converted to \JSON.
#
# Argument +opts+, if given, contains options for the generation, and must be a
# {Hash-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash-Convertible+Objects].
# 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-convertible object}[doc/implicit_conversion_rdoc.html#label-Array-Convertible+Objects]
# (implementing +to_ary+), returns a \String containing a \JSON array:
# 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-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash-Convertible+Objects],
# return a \String containing a \JSON object:
# 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"}'
Expand Down Expand Up @@ -436,8 +427,7 @@ class << self
# BEWARE: This method is meant to serialise 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 +opts+, if given, contains options for the parsing, and must be a
# {Hash-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash+Convertible+Objects].
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
# The default options can be changed via method JSON.load_default_options=.
#
Expand Down