We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e5fc6b2 commit b545688Copy full SHA for b545688
lib/spring/json.rb
@@ -13,7 +13,7 @@
13
module Spring
14
module JSON
15
def self.load(string)
16
- OkJson.decode(string)
+ OkJson.decode(string.dup.force_encoding("utf-8"))
17
end
18
19
def self.dump(data)
test/unit/json_test.rb
@@ -8,5 +8,11 @@ class JsonTest < ActiveSupport::TestCase
8
9
test 'can encode' do
10
assert_equal('{}', Spring::JSON.dump({}))
11
- end
+ end
12
+
+ test 'can encode and decode unicode characters' do
+ encoded = Spring::JSON.dump({"unicode_example"=>"©".b})
+ assert_equal('{"unicode_example":"©"}'.b, encoded)
+ assert_equal({"unicode_example"=>"©"}, Spring::JSON.load(encoded))
0 commit comments