json: Properly handle trailing comma error in object decoding.

Closes #16945
Currently json uses a custom `Stack` where `pop` does not return a value, so we need to use `is_empty()`.