Skip to content

Commit a5c160f

Browse files
committed
Add missing documentation for allow_control_characters parsing option
1 parent 4808fee commit a5c160f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/json.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@
173173
# When enabled:
174174
# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
175175
#
176+
# ---
177+
#
178+
# Option +allow_control_characters+ (boolean) specifies whether to allow
179+
# unescaped ASCII control characters, such as newlines, in strings;
180+
# defaults to +false+.
181+
#
182+
# With the default, +false+:
183+
# JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
184+
#
185+
# When enabled:
186+
# JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
187+
#
176188
# ====== Output Options
177189
#
178190
# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;

0 commit comments

Comments
 (0)