This project is archived and is in readonly mode.

#1576 ✓invalid
ronin-24025 (at lighthouseapp)

to_json <> to_xml (dasherize => true, methods => other_ids)

Reported by ronin-24025 (at lighthouseapp) | December 15th, 2008 @ 12:30 PM | in 2.x

I've been developing a Rails application, the sole purpose of which is to act as a REST API, sending and receiving JSON or XML.

Along the way, numerous discrepancies between to_json and to_xml have popped up which have proved to be a royal pain in the arse:

  1. to_xml misrepresents the other_ids result (included using the 'methods' option) as a concatenated string, when it should in fact be an array of ids. to_json gets this right.

  2. to_xml accepts the dasherize => true option. to_json does not.

I'm not yet familiar enough with the Rails source to provide an acceptable patch, but I would like to contribute in so far as at least providing this feedback.

Comments and changes to this ticket

  • Frederick Cheung

    Frederick Cheung December 23rd, 2008 @ 11:02 AM

    Is dasherize useful for json ? I can't think you would ever want that since it means that you have to access things as x['foo-bar'] since x.foo-bar is obviously invalid (or rather doesn't mean x['foo-bar'])

    If you're interested in playing around the appropriate files are active_record/lib/serialization.rb, active_record/lib/serializers/json_serializer.rb, active_record/lib/serializers/xml_serializer.rb

  • Pratik

    Pratik March 13th, 2009 @ 02:45 PM

    • State changed from “new” to “invalid”
    • Assigned user set to “Frederick Cheung”

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages