intridea/multi_json — pull request #152 by josepjaume (2014-12-01 11:50:26+00:00)
Title: Deal with nil

When working with serializable attributes in `rails`, I noticed a small inconsistency between ruby's `JSON` and `MultiJson` - the way it deals with `nil`.

On `rails`, I'm able to use the `JSON` object as a replacement to its built-in `YAMLColumn` the following way:

```ruby
class Model < ActiveRecord::Base
serialize :data, JSON
end
```

This happens because `serialize` expects an object that provides the `load` and `dump` methods. Although `MultiJson` complies with that, it throws `MultiJson::ParseError` on nil values, which is inconsistent with the default `JSON` implementation. Same happens when dumping.

It might look coupled to rails, but dealing with nil values (and returning `nil` as well) looks totally fine to me.