Improving and Deprecating Ruby's JSON gem APIs
This post details the reasoning and specifics behind the maintainer's improvements and deprecations to the Ruby JSON gem's APIs. Three key areas are addressed: First, the unsafe `create_additions: true` option is deprecated, with `JSON.unsafe_load` or explicit option passing recommended. Second, the default tolerance for duplicate keys is deprecated, suggesting the use of `allow_duplicate_key: true`. Lastly, while not deprecating `Object#to_json`, a new `JSON::Coder` API is introduced, offering a safer and more flexible JSON serialization method, addressing global behavior and configuration issues. The author emphasizes the need to weigh the costs and benefits of deprecating APIs and highlights that the new APIs enhance security and reduce the risk of errors.
Read more