I have the following structure :
a = { 'x' => [1,2,3] }
In Rails 3.0 with ruby 1.8, the conversion to JSON works as expected :
a.to_json
=> “{\”x\”:[1,2,3]}”
In Rails 3.1 with ruby 1.9.3p125, the array is transformed into a hash :
a.to_json
=> “{\”x\”:{\”1\”:null,\”2\”:null,\”3\”:null}}”
I can’t find any documentation explaining the difference in behaviour between the two versions, nor any way to preserve the expected output in Rails 3.1. Any clues ?
The problem is actually related to one of the gems installed on the Gemfile, which returns an incorrect result for to_json calls.
Thanks for the help.