mirror of https://github.com/rails/rails
ab01f9f3da
Previously jsonify would call `.as_json` for Integer, nil, true, and false, even though those types are considered "JSON-ready". Technically a user could have overridden `.as_json` for these types but I can't imagine a use case and I don't think we should support that. I left the same behaviour of calling `.as_json` for generic "Numeric" as that can have user subclasses where one may have implemented as_json. This behaviour is also used for Float (which coerces NaN/Infinity/-Infinity into nil). This also adds Symbol to the list of "JSON-ready" types, to avoid unnecessarily casting them to strings (possible as we no longer perform escaping on input). The output of jsonify should never be user visible before it is passed through JSON.generate, so I don't think this should be a user facing change. This also corrects our handling of Hash to call to_s on all keys, matching the behaviour of `.as_json` and JSON's requirement that keys are Strings (Symbols are also permitted as JSON knows to convert them to a String). |
||
---|---|---|
.. | ||
decoding_test.rb | ||
encoding_test.rb | ||
encoding_test_cases.rb |