title: Add virtual attribute to json output
body: <p>Let's say I have an app that handles a TODO list. The list has finished and unfinished items. Now I want to add two virtual attributes to the list object; the count of finished and unfinished items in the list. I also need these to be displayed in the json output.</p>
  
  <p>I have two methods in my model which fetches the unfinished/finished items:</p>
  
  <pre><code>def unfinished_items 
    self.items.where("status = ?", false) 
  end 
  
  def finished_items 
    self.items.where("status = ?", true) 
  end
  </code></pre>
  
  <p>So, how can I get the count of these two methods in my json output?</p>
  
  <p>I'm using Rails 3.1</p>