You can put everything inside `format.json` like this:

```ruby
respond_to do |format|
  format.json do
    if something...
      render :json => { ... }
    elsif something_else ...
      render :json => { ... }
    else
      render :json => { ... }
    end
  end
end