> > Try out the json_serializer plugin and let me know what you think.

Funny, sometimes I feel like I'm tuned-in to the Sequel zeitgeist. :-)

The plugin looks really nice overall, but I did have a couple
questions.  Here's my example code:

  @users = User.all
  puts @users.first.to_json
  puts @users.to_json

This yields:

  {"json_class":"User","first":"a","last":"b","dob":"2010-06-05
20:16:36 -0700"}

  [{"json_class":"User","first":"a","last":"b","dob":"2010-06-05
20:16:36 -0700"},
   {"json_class":"User","first":"b","last":"c","dob":"2010-06-05
20:16:36 -0700"}]


Questions:

1) How difficult would it be to turn on the "root node" behavior that
some JSON frameworks expect?  So something like:

  @user.to_json(:root => true)
  @users.to_json(:root => true)

Which would change the output to:

  {"user": {"first":"a","last":"b","dob":"2010-06-05 20:16:36 -0700"}}

  {"users": [
    {"user": {"first":"a","last":"b","dob":"2010-06-05 20:16:36
-0700"}},
    {"user": {"first":"b","last":"c","dob":"2010-06-05 20:16:36
-0700"}}
  ]}


2) For the options that make sense, would it be possible to propagate
these to class-level settings as well?  So:

   Sequel::Model.plugin :json_serializer, :naked => true, :root =>
true

Thoughts?

Thanks,
Nate

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to