flori/json — Issue #101: jruby-json: json/ext makes incorrect assumptions about character encoding
Author: perlun
Created: 2011-10-10 15:40:47+00:00
State: open

Hi!

If I run "my_object.to_json", using "require 'json/ext'" (on JRuby 1.6.4, in Ruby 1.9 mode), I get output which is encoded as UTF-8 - even though my JVM is running with Windows-1252. This causes problems, because the output is later on encoded as UTF-8 again (it gets sent as the output from a servlet). Hence, it gets double-encoded and all non-ASCII characters are scrambled.

(This can easily be seen/tested on Windows where the JVM default encoding is normally not UTF-8, but Windows-1252. I guess the default on Linux is UTF-8, which could describe why the bug hasn't been seen earlier.)

The behavior is correct when using json/pure => it seems to be related specifically to the json/ext

I am using json-1.5.0-java.

Best regards,
Per Lundberg