Skip to content

Commit

Permalink
Improve documentation for JSON#parse
Browse files Browse the repository at this point in the history
Adds information about raised error when fail to parse
  • Loading branch information
brunojabs committed Jun 23, 2020
1 parent 3dabe30 commit bb83715
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ext/json/lib/json/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class MissingUnicodeSupport < JSONError; end
module_function

# Parse the JSON document _source_ into a Ruby data structure and return it.
# It raises JSON::ParserError if it fails to parse.
#
# _opts_ can have the following
# keys:
Expand All @@ -158,6 +159,7 @@ def parse(source, opts = {})
# Parse the JSON document _source_ into a Ruby data structure and return it.
# The bang version of the parse method defaults to the more dangerous values
# for the _opts_ hash, so be sure only to parse trusted _source_ documents.
# It raises JSON::ParserError if it fails to parse.
#
# _opts_ can have the following keys:
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
Expand Down
1 change: 1 addition & 0 deletions ext/json/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,7 @@ case 9:
*
* Parses the current JSON text _source_ and returns the complete data
* structure as a result.
* It raises JSON::ParseError if fail to parse.
*/
static VALUE cParser_parse(VALUE self)
{
Expand Down
3 changes: 2 additions & 1 deletion ext/json/parser/parser.rl
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ static VALUE cParser_parse_quirks_mode(VALUE self)
* call-seq: parse()
*
* Parses the current JSON text _source_ and returns the complete data
* structure as a result.
* structure as a result.A
* It raises JSON::ParseError if fail to parse.
*/
static VALUE cParser_parse(VALUE self)
{
Expand Down

0 comments on commit bb83715

Please sign in to comment.