This project is archived and is in readonly mode.
#to_json behavior still different between Rails 2.3.2.1 and Rails 2-3-stable
-
Michael Koziarski
- Assigned user set to Rick
Given this I think we have no choice but to revert the rails_to_json change from 2-3-stable and figure out a plan for deprecation.
It can remain in master of course.
-
Michael Koziarski
- Milestone changed from 2.x to 2.3.3
-
Jeremy Kemper
- State changed from new to open
- Assigned user changed from Rick to Jeremy Kemper
What a headache. Overriding to_json to provide custom JSON representations is a bad API decision. Instead we should be overriding a dump_json method to provide a Hash, Array, etc to encode. Then we don't have to walk the path of
class Custom def to_json(*strange_internal_state)
{ :alternate => 'representation' }.to_json(*strange_internal_state)
Instead we have the much cleaner
end end
class Custom def dump_json(options_hash)
{ :alternate => 'representation' }
I'm reverting the change in 2-3-stable but will move to this new API in master.
end end -
Michael Koziarski
Sounds like an improvement for sure. Not sold on the name, but it
beats the 'return a json string' api that's very brittle.When you revert this from 2-3-stable move this ticket's milestone to 3.0
-
Jeremy Kemper
The naming mirrors Marshal's choice of marshal_dump/load
-
Repository
- State changed from open to resolved
(from [4a78dae2ab43b5ba94fa06b345e9edeb0305fe44]) Revert rails_to_json -> to_json so we don't break compatibility
[#2753 #to_json behavior still different between Rails 2.3.2.1 and Rails 2-3-stable state:resolved] http://github.com/rails/rails/commit/4a78dae2ab43b5ba94fa06b345e9ed...