This project is archived and is in readonly mode.

#652 ✓committed
Noel Rappin

Stack error with Hash.to_json for nested number values

Reported by Noel Rappin | July 18th, 2008 @ 04:51 PM | in 2.x

Here's the test

    hash = {
      "CHI" => {
        :dislay_name => "chicago",
        :latitude => 123.234
    result = hash.to_json

And the result

test: Institution should output json. (InstitutionTest):
SystemStackError: stack level too deep

Poking around, converting the number to a string did not trigger the problem, and using a flat hash rather than a nested hash also did not. I'm wondering if this is a odd side effect of the stack check to avoid circular references?

Comments and changes to this ticket

  • Dan Barry

    Dan Barry October 12th, 2008 @ 09:42 PM

    • Tag changed from 2.1, activesupport, bug to 2.1, activesupport, bug

    I wrote a unit test for this that passed on edge rails, so it looks like this has been fixed already.

  • Repository

    Repository October 12th, 2008 @ 10:25 PM

    • State changed from “new” to “committed”

    (from [0d4dbb3dfaec8355e072d8f758de40a277f2f009]) test nested hash with float

    [#652 state:committed]

    Signed-off-by: Jeremy Kemper

  • Noel Rappin

    Noel Rappin December 1st, 2008 @ 08:14 PM

    • Tag changed from 2.1, activesupport, bug to 2.1, activesupport, json

    Oddly, I'm still having the problem, with Rails 2.2. Just saw it when trying to run the open flash chart example,

    The resulting JSON should look like this

    {"title": "Tasker", "elements": [{"type": "bar_glass", "values": [1, 2]}]}

    But I'm getting the same stack overflow error. The original example doesn't work for me either.

    noel$ script/console Loading development environment (Rails 2.2.2)

    hash = { ?> "CHI" => { ?> :dislay_name => "chicago", ?> :latitude => 123.234


    => {"CHI"=>{:dislay_name=>"chicago", :latitude=>123.234}}

        result = hash.to_json
  • Noel Rappin

    Noel Rappin December 1st, 2008 @ 08:16 PM

    Asking around my group, the original example works for some of us, but not for others in a script/console session.

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by