2 more JSON / XML feature parity patches before Rails 2.0

I'd really like to see just 2 more functional changes to the JSON serialization/encoding before we get to Rails 2.0.

First, and I think this is really crucial because without it all the efforts to output JSON from ActiveRecord objects would have been half in vain, is to allow us to do this in controllers:

  @authors = Author.find(:all)

  render :json => @authors.to_json(:only => :name)

Currently you can only to_json on a _single_ AR::B instance, but not for lists of them. I've a patch at http://dev.rubyonrails.org/ticket/9751 that does this but needs verification and probably more input.

The other change, while not as serious, is to get an unambiguous Time, Date and DateTime #to_json format, i.e. to get dates encoding to JSON like this:   2007/10/01 12:15:02 CDT instead of:   0/01/2007 12:15:02 CDT

gbuesing has a patch at http://dev.rubyonrails.org/ticket/9750 that needs your help with verification and ideas on whether this different date format would work.

This is the last sprint before Rails 2.0 I'm guessing so if you use JSON at all please do chip in! Thanks for listening.

Cheers, Chu Yeow

I agree!!! Please!!!

Thanks for checking in http://dev.rubyonrails.org/ticket/9751 (and improving a few things too), bitsweat!

I've added another patch based off gbuesing's for his ticket http://dev.rubyonrails.org/ticket/9750 that requires more input and testing across different platforms.

If anyone can help verify and test it or point out any flawed assumptions, it'd be very very helpful.

Thanks!

Cheers, Chu Yeow

I have a very heavy javascript app that depends on JSON responses from the server. It's been using this excellent asp.net JSON serializer and have been running fine. I based my decision to port my server code to rails because most of my app was in the javascript with very minimal server code. Pretty much all the server did was serialize the database tables/rows into json for the client. But, to my sunrise, rails was completely not suited for this out of the box!

Anyways, I'll definetly test this out since I have a great need for this support.