From 5d5e0c2c48ee20e0f0b506e8e905c17dc8497f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Fri, 20 Feb 2026 11:58:01 +0100 Subject: [PATCH] Use single quotes for allow_invalid_escape doc Instead of using %{} which works like double-quoted string and allows escape sequences and in which "other escaped characters (a backslash followed by a character) are interpreted as the character", change the examples for `allow_invalid_escape` to use single-quotes strings, in which "any other character following a backslash [except ' and \] is interpreted as is: a backslash and the character itself." This makes it clearer the JSON document only includes a single backslash. --- lib/json.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/json.rb b/lib/json.rb index 39e414be..f28be7f7 100644 --- a/lib/json.rb +++ b/lib/json.rb @@ -201,10 +201,10 @@ # defaults to +false+. # # With the default, +false+: -# JSON.parse(%{"Hell\\o"}) # invalid escape character in string (JSON::ParserError) +# JSON.parse('"Hell\o"') # invalid escape character in string (JSON::ParserError) # # When enabled: -# JSON.parse(%{"Hell\\o"}, allow_invalid_escape: true) # => "Hello" +# JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello" # # ====== Output Options #