We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e5fc6b2 + 303bff7 commit 046d50aCopy full SHA for 046d50a
lib/spring/json.rb
@@ -13,6 +13,7 @@
13
module Spring
14
module JSON
15
def self.load(string)
16
+ string = string.dup.force_encoding("utf-8") unless string.encoding == Encoding::UTF_8
17
OkJson.decode(string)
18
end
19
test/unit/json_test.rb
@@ -6,7 +6,12 @@ class JsonTest < ActiveSupport::TestCase
6
assert_equal({"unicode_example"=>"©"}, Spring::JSON.load('{"unicode_example": "\u00A9"}'))
7
8
9
+ test 'can decode binary strings with valid UTF8 characters' do
10
+ string = "{\"PS1\":\"\xEF\x90\x98 main \xEE\x9E\x91 v3.4.2\"}".b
11
+ assert_equal({"PS1"=>" main v3.4.2"}, Spring::JSON.load(string))
12
+ end
+
test 'can encode' do
assert_equal('{}', Spring::JSON.dump({}))
- end
0 commit comments