title: rails 3 json custom json formatting
body: <p>I have a collection of @clients with attributes id and email
  I want to render this json format</p>
  
  <pre><code> [ 
   {"id":" 1","label":"johndoe@yahoo.com","value":"1"},{"id":"  2","label":"paulsmith@gmail.com.com","value":"2"}
  ]
  </code></pre>
  
  <p>in clients_controller I defined the following method</p>
  
  <pre><code>def search
      @clients = Client.where(:user_id =&gt; current_user.id).select('id','email')
      render :partial =&gt; "clients/search"
    end
  </code></pre>
  
  <p>and here is the view _search.json.erb</p>
  
  <pre><code>[ 
   &lt;%= raw @client.map{|client| '{"id":"' +" #{client.id}" +'","label":"' + "#{client.email}" +  '","value":"' +"#{client.id}" +'"}' }.join(",") %&gt;
  ]
  </code></pre>
  
  <p>this is working, but I found it fugly...is there a more elegant way to generate a custom json format in a view?</p>