Skip to content

Commit eed753f

Browse files
committed
Add missing parser options documentation
1 parent 6fc2c4b commit eed753f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/json.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,23 @@
143143
# ruby = JSON.parse(source, {allow_nan: true})
144144
# ruby # => [NaN, Infinity, -Infinity]
145145
#
146+
# ---
147+
#
148+
# Option +allow_trailing_comma+ (boolean) specifies whether to allow
149+
# trailing commas in objects and arrays;
150+
# defaults to +false+.
151+
#
152+
# With the default, +false+:
153+
# JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
154+
#
155+
# When enabled:
156+
# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
157+
#
146158
# ====== Output Options
147159
#
160+
# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
161+
# defaults to +false+.
162+
#
148163
# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
149164
# should be Symbols;
150165
# defaults to +false+ (use Strings).

0 commit comments

Comments
 (0)