mattt/sinatra-param — pull request #8 by rlipman (2012-06-19 21:09:05+00:00)
Title: Fixes for JSON post bodies

I found a Rack middleware that adds JSON post bodies to the `params` hash. This pull request fixes some of the gotchas when dealing with already parsed JSON.

So far, I've only found one issue that needed fixing:

* Don't coerce Arrays and Hashes if they're already that type from JSON.parse

Obtaining the Rack middleware:

Gemfile:

```ruby
gem 'rack-contrib', git: 'git@github.com:rack/rack-contrib', ref: 'b7237381e412852435d87100a37add67b2cfbb63'
```

Sinatra app:

```ruby
require 'sinatra/base'
require 'rack/contrib/post_body_content_type_parser'
class MyApp < Sinatra::Base
use Rack::PostBodyContentTypeParser
...
```

And JSON will be automatically placed in the `params` hash on POST routes.

It needs git because there was a bug with `Content-type:application/json;charset=UTF-8` where it wouldn't recognize that content-type correctly. I'm personally using that specific ref because it's the commit that fixed the bug, and the latest commit for that file.