Perhaps this is out of `as_json` responsibility. If you wish to use circular reference detection, you should pass the encoder as an option (as the code was before, here).