Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

JSON.dump({}) raise NoMethodError

#3485

This code raise NoMethodError.

  require 'rubygems'
  require 'activesupport'
  JSON.dump({}) # raise NoMethodError

but,

  require 'rubygems'
  require 'json'
  JSON.dump({}) # => "{}"

In 'active_support/json/encoders/hash.rb' Hash#as_json or Hash#to_json is wrong.
I attached a simple patch for this problem.

Reported by okkez · November 12th, 2009 @ 01:27 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. okkez
    okkez

    I attached a wrong patch(a.diff). I did not want to change magic comment.
    I reattach a patch(b.diff).

    November 13th, 2009 @ 12:16 PM

  2. windock
    windock

    Can reproduce with ActiveSupport 2.3.5 and Json 1.2.0
    Patch fixes the problem.

    February 17th, 2010 @ 12:38 AM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to resolved
    • Importance changed from to

    Cannot reproduce with Active Support 3 therefore I am assuming this is fixed.

    Closing.

    October 14th, 2010 @ 08:14 AM

  4. bingbing