json: Properly handle trailing comma error in object decoding.

Closes #16945
Could you express this as a `match` instead?

```rust
match self.stack.pop() {
    Some(..) => {}
    None => return self.error_event(TrailingComma)
}
```