Last active
December 11, 2015 21:28
-
-
Save pawel2105/4662360 to your computer and use it in GitHub Desktop.
ActiveSupport::JSON.decode breaking when updating to Rails 2.3.16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@object = "{'source': 'Direct', 'details': 'Unknown', 'vdate': 1333236870729}" | |
Rails 3.2.15 | |
> ActiveSupport::JSON.decode(@object) | |
# => {"details"=>"Unknown", "vdate"=>1333236870729, "source"=>"Direct"} | |
Rails 3.2.16 | |
> ActiveSupport::JSON.decode(@object) | |
# => ActiveSupport::OkJson::Error: invalid character at "'source': 'D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from /Users/schopenhauer/.rvm/gems/ruby-1.8.7-p370@contiki/gems/activesupport-2.3.16/lib/active_support/json/backends/okjson.rb:180:in `lex' | |
from /Users/schopenhauer/.rvm/gems/ruby-1.8.7-p370@contiki/gems/activesupport-2.3.16/lib/active_support/json/backends/okjson.rb:46:in `decode' | |
from /Users/schopenhauer/.rvm/gems/ruby-1.8.7-p370@contiki/gems/activesupport-2.3.16/lib/active_support/json/backends/okjson.rb:612:in `decode' | |
from /Users/schopenhauer/.rvm/gems/ruby-1.8.7-p370@contiki/gems/activesupport-2.3.16/lib/active_support/json/decoding.rb:14:in `__send__' | |
from /Users/schopenhauer/.rvm/gems/ruby-1.8.7-p370@contiki/gems/activesupport-2.3.16/lib/active_support/json/decoding.rb:14:in `decode' |
This happens in rails 3.0.20 as well. Apparently single-quotes no longer work, it will only accept double-quotes. Replacing single-quotes with double-quotes is not a viable solution; this was a minor release and should not introduce backwards incompatibilities.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[7] pry(main)> @object = "{"source": "Direct", "details": "Unknown", "vdate": 1333236870729}"
=> "{"source": "Direct", "details": "Unknown", "vdate": 1333236870729}"
[8] pry(main)> ActiveSupport::JSON.decode(@object)
=> {"source"=>"Direct", "details"=>"Unknown", "vdate"=>1333236870729}