Conversation
This is because the new encoder will no longer support encode_json. Therefore our only choice is to return `to_i` or `to_s` in `BigDecimal#as_json`. Since casting a BigDecimal to an integer is most likely a lossy operation, we chose to encode it as a string. Support for encoding BigDecimal as a string will return via the `activesupport-json_encoder` gem.
Got all the tests passing again. Support for `encode_json` has been removed (and consequently the ability to encode `BigDecimal`s as numbers, as mentioned in the previous commit). Install the `activesupport-json_encoder` gem to get it back.
|
Numers are in! Full stack benchmark: this uses Discourse's Raw JSON benchmark: this uses the same Discourse seed data generator and calculates the time it takes to dump various data. Seems like the patched version is faster than both 4.0.1 and current master! I also started a draft on a document that goes into details on the expected behaviour of the various components. (I swear it's not as scary as it looks!) The current implementation might not be 100% inline with the draft yet, but we can work on it in future PRs. I do plan to turn that into a higher-level user guide at some point. |
|
The old encoder is extracted to here: https://github.com/vanruby/activesupport-json_encoder |
|
@chancancode I just want to say thank you so much for this work 👏 |
Also added the missing CHANGELOG entry for rails#12183 @ 80e7552 and 4d02296.
|
@nixme 💛 |
Also added the missing CHANGELOG entry for rails#12183 @ 80e7552 and 4d02296.
|
👍 |
|
4.1 |
Due to rails/rails#9212 rendering json caused performance issues and had to be replaced in OBS. We started to use yajl-ruby instead. Supposedly this has been solved in rails meanwhile and we can revert the workaround. See rails/rails#12183 for details Partial revert of 148b7a9
Goals
ActiveSupport's pure-Ruby JSON encoder with one based on thejsongemencode_jsonsupport) by moving the old encoder into a gemjsongem incompatibilities (via JSON gem compatibility #12862)as_jsonnot being applied recursivelyNice to have
encode_jsongem can take advantage of that)Misc TODOs
to_jsonin gerenral