Json put/post/update

Hey all… I’m building a RESTful JSON API and I find myself writing
this:

JSON.parse(request.body.read)

…over and over in every controller action that accepts JSON in the
request body (which is a lot of actions).

Does rails have a better built-in way to keep the code more DRY? Or
should I solve that somehow myself?

Thanks,

Cainus

On Aug 17, 1:59am, Cainus [email protected] wrote:

If the content-type is set properly on the request, rails should
populate params with the parsed json itself.

Fred

You can also use to_josn method to get the json string. Its built-in
method
in rails.
when request arrives at server you can get json data in parameter which
you
can fatch by params[:]
You can view the whole request ad json in rails by using req.as_json
method.

On Wed, Aug 17, 2011 at 1:22 PM, Frederick C. <