fixed assertion logic in `Writer` and `PrettyWriter` with respect to object `key` detection