We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e5fc6b2 commit 8676bebCopy full SHA for 8676beb
lib/spring/json.rb
@@ -13,6 +13,7 @@
13
module Spring
14
module JSON
15
def self.load(string)
16
+ string.force_encoding("utf-8")
17
OkJson.decode(string)
18
end
19
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