ruby / json

JSON implementation for Ruby
https://ruby.github.io/json
Other
673 stars 326 forks source link

JSON dumping should support a parameter to skip nil values #590

Open HoneyryderChuck opened 3 months ago

HoneyryderChuck commented 3 months ago

It's something one can easily do by calling .compact on the hash passed to JSON.dump, with the caveat of generating an extra object. Ideally one could do something of the kind:


JSON.dump_default_options[:ignore_null] = true

JSON.dump({bang: nil}) #=> '{}'