Move the JSON extension require statements to the right place.

In [1], I made server fixes to #12203 which I apparently didn't port
over. The problem is partially addressed in #12710, this commit fixes
the rest.

The requires being moved here are used for in the `to_json` and
`as_json` extensions, so there should be required there instead.

Sorry guys :disappointed_relieved:

[1] https://github.com/chancancode/rails/commit/e15f488c087e7568a814a4a65b233114578b58b7