class Jbuilder
def ignore_nil!(value = true)
{}
json.id User.new.id
json.ignore_nil!
{ "id": null }
json.id User.new.id
json.ignore_nil! false
Example:
not to receive keys which have null values.
for JSON clients that don't deal well with nil values, and would prefer
If you want to skip adding nil values to your JSON hash. This is useful
def ignore_nil!(value = true) @ignore_nil = value end