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
243 stars 52 forks source link

Re-introduce escaping of tabs. #34

Closed jrallison closed 12 years ago

jrallison commented 12 years ago

I ran into a problem upgrading to the latest version of json_builder. A recent commit refactored String#json_escape, and removed escaping of tabs.

The result:

irb> val = "a\tb"
=> "a\tb"
irb> j = JSONBuilder::Compiler.generate { v val }
=> "{\"v\": \"a\tb\"}"
irb> JSON.parse j
JSON::ParserError: 757: unexpected token at '{"v": "a   b"}'
    from /Users/jrallison/.rbenv/versions/1.9.3-p194-perf/gemsets/customerio/gems/json_pure-1.7.4/lib/json/common.rb:155:in `parse'
    from /Users/jrallison/.rbenv/versions/1.9.3-p194-perf/gemsets/customerio/gems/json_pure-1.7.4/lib/json/common.rb:155:in `parse'
    from (irb):6
    from /Users/jrallison/.rbenv/versions/1.9.3-p194-perf/gemsets/customerio/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
    from /Users/jrallison/.rbenv/versions/1.9.3-p194-perf/gemsets/customerio/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
    from /Users/jrallison/.rbenv/versions/1.9.3-p194-perf/gemsets/customerio/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

This pull request adds back tab escaping.

travisbot commented 12 years ago

This pull request passes (merged 24f89f6b into 1def4d01).

dewski commented 12 years ago

Thanks for fixing this and adding a test as well. :metal: I cut a new release at 3.1.6 for you to use.