Improvements to Rails' JSON Support

I’m travelling at the moment, so posting has slowed down after three weeks of daily updates. Nevertheless I’ve just about managed to keep up with my newsreader and was pleased to see that some attention has been going into the JSON support in ActiveResource.

Previously parsing JSON that couldn’t be easily handled by the YAML parser was a bit of a pain. Now it’s simply a case of calling:

ActiveSupport::JSON.decode(json_string)

And the JSON param_parser I referenced in my “Versatile RESTful APIs Beyond XML” article no longer needs extra help. It’s simply:

ActionController::Base.param_parsers[Mime::JSON] = Proc.new do |data|
  ActiveSupport::JSON.decode(post)
end

Tags: , ,

1 comment

  1. Nice!! But still only on Edge :( In the meanwhile you shall keep json.rb around