From: Jeremy Evans Date: 2010-02-19T16:49:07+09:00 Subject: Re: Convert Sequel Dataset to JSON Object Phil Tayo wrote: > [{"country":"uk","task":"qwdwd","created_at":{"json_class":"Time","n":407000000,"s":1266543411},"id":3}] >>> >>> I'll have to look into this when I have more time. >> >> You probably want to add Time#to_json to do something, maybe >> to_s.to_json or strftime(...).to_json. >> >> Jeremy > > Thanks but when I do this: Task.naked.all.to_s.to_json it converts the > whole object to one big string. I'm not sure how to specify to to_s for > only one field of my object i.e. "created_at". I assume that you are fairly new to ruby, so I'll spell it out for you: class Time def to_json to_s.to_json end end class Sequel::Dataset def to_json naked.all.to_json end end class Sequel::Model def self.to_json dataset.to_json end end Task.to_json Jeremy -- Posted via http://www.ruby-forum.com/.