This project is archived and is in readonly mode.

#6047 new
Ken Mayer

[Patch] JSON.generate raises exception in v3.0.2 + json_pure => '~>1.4.3'

Reported by Ken Mayer | November 23rd, 2010 @ 06:14 PM

When using the json_pure gem, this fails in v3.0.2, but succeeds in v3.0.0. It does not fail with json 1.4.6 with native extensions.

Here's the commit the created the bug (determined by git bisect start v3.0.2 v3.0.0):

https://github.com/rails/rails/commit/33b954005cd71f1bfba1beca29680...

How to reproduce

You'll need the following Gemfile in a test rails application:

source 'http://rubygems.org'
gem 'rails', :path => '../rails/'
gem 'json_pure'

Then run this on the command line:

bundle exec rails runner 'JSON.generate([0])'

Here's a stack trace:

/Users/kmayer/Documents/rails/railties/lib/rails/commands/runner.rb:50: undefined method `merge' for #<JSON::Pure::Generator::State:0x102181890> (NoMethodError)
    from /Users/kmayer/Documents/rails/activesupport/lib/active_support/json/encoding.rb:46:in `encode'
    from /Users/kmayer/Documents/rails/activesupport/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
    from /Users/kmayer/Documents/rails/activesupport/lib/active_support/json/encoding.rb:45:in `encode'
    from /Users/kmayer/Documents/rails/activesupport/lib/active_support/json/encoding.rb:30:in `encode'
    from /Users/kmayer/Documents/rails/activesupport/lib/active_support/core_ext/object/to_json.rb:15:in `to_json'
    from /Users/kmayer/.rvm/gems/ruby-1.8.7-head@jsonbug/gems/json_pure-1.4.6/lib/json/pure/generator.rb:228:in `generate'
    from /Users/kmayer/.rvm/gems/ruby-1.8.7-head@jsonbug/gems/json_pure-1.4.6/lib/json/common.rb:210:in `generate'
    from (eval):1
    from /Users/kmayer/Documents/rails/railties/lib/rails/commands.rb:39:in `eval'
    from /Users/kmayer/Documents/rails/railties/lib/rails/commands/runner.rb:50
    from /Users/kmayer/Documents/rails/railties/lib/rails/commands.rb:39:in `require'
    from /Users/kmayer/Documents/rails/railties/lib/rails/commands.rb:39
    from script/rails:6:in `require'
    from script/rails:6

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

People watching this ticket

Pages