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 aa6f39e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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
2 changes: 2 additions & 0 deletions ext/json/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,8 @@ 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

0 comments on commit aa6f39e

Please sign in to comment.