This project is archived and is in readonly mode.
to_xml method not available in all objects as opposed to to_json
-
Dan Pickett
- Tag changed from rails3 to bugmash, rails3
-
Rohit Arondekar
Neeraj, your example doesn't work anymore. Me.to_json also gives undefined method. I'm guessing something has changed recently because of the conflict with json_pure gem.
Also why are you calling to_json or to_xml on a class?
I'm guessing it was done like that because XML was meant to be a data interchange format while JSON was meant to be for serializing objects.
The way to_xml works is, it calls the .to_xml method of each item in the collection and groups them together. This reflects xml's data interchange purpose.
Whereas any object can be serialized into JSON.
You should discuss this in #rails-contrib to get a better answer maybe. Or do you want me to close this ticket?
-
Neeraj Singh
I was just pointing out inconsistency between to_json and to_xml. As you mentioned to_json is also reporting the same problem now. So this ticket can be closed.
Thanks for the follow up.
-
Rohit Arondekar
- State changed from new to invalid