rails/activesupport/test/json
John Hawthorn ab01f9f3da Consider Symbol "JSON-ready", improve jsonify
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).
2023-06-30 11:38:38 -07:00
..
decoding_test.rb Fix word case. `json` -> `JSON` 2022-09-17 04:11:36 +10:00
encoding_test.rb Fixes https://github.com/rails/rails/issues/47267 2023-02-06 15:13:47 +00:00
encoding_test_cases.rb Consider Symbol "JSON-ready", improve jsonify 2023-06-30 11:38:38 -07:00