Added `space` argument to `toJSON` methods