[Finishes #83890480] Rework toJSON to be conformant with JSON package.

@mhfrantz This PR contains just the changes for toJSON. Let's merge this first and then I'll submit a replacement for #24.

We had methods named toJSON that were async. This interfered with
the workings of JSON.stringify. In the course of fixing this problem
it became clear that we could remove a significant amount of code
that essentially duplicated portions of JSON.stringify.