Fix toJSON plugin to work as intended.