dewski / json_builder

Rails provides an excellent XML Builder by default to build RSS and ATOM feeds, but nothing to help you build complex and custom JSON data structures. JSON Builder is here to help.
http://garrettbjerkhoel.com/json_builder/
MIT License
244 stars 52 forks source link

use String#to_json to prevent UTF8 byte splicing #18

Closed neerfri closed 12 years ago

neerfri commented 12 years ago

I've had problems with UTF8 text in json responses. The problem is rooted in ruby's String#inspect that splices the last bytes of the string due to incorrect count of bytes. String#to_json handles this well.

dewski commented 12 years ago

Thanks for the patch! Can you provide some test cases to make sure this doesn't break UTF8 in future commits?

neerfri commented 12 years ago

Not so easy. As far as I know this will only happen in versions of ruby where UTF8 strings are mishandled.

Is there a way to test against this ?

On Wed, Feb 8, 2012 at 9:34 PM, Garrett Bjerkhoel < reply@reply.github.com

wrote:

Thanks for the patch! Can you provide some test cases to make sure this doesn't break UTF8 in future commits?


Reply to this email directly or view it on GitHub: https://github.com/dewski/json_builder/pull/18#issuecomment-3874333

dewski commented 12 years ago

This has been fixed by 1cb778b0ef25ae179ea5c92685bc4bafc8771d3d