On Sun, Sep 10, 2017 at 2:24 AM, Andrea Faulds <a...@ajf.me> wrote:

> Hi everyone,
>
> Craig Duncan previously sparked discussion here about JSON's
> error-handling behaviour. Unfortunately, his attempt to change it seems not
> to have gone anywhere, but I have his blessing to try this other approach
> instead.
>
> So here's an RFC: https://wiki.php.net/rfc/json_throw_on_error
>
> The feature can be described in a single paragraph (in fact, the title is
> pretty much enough, the patch is just detail) but it's better to go through
> the proper RFC process.
>
> Please tell me what you think.
>
>
I think that it makes sense in general. There are just couple of things
that are not described in RFC.

Currently it has higher priority than JSON_PARTIAL_OUTPUT_ON_ERROR. I think
that if someone specify this constant, then the partial output is required
and it should be preferred. In any case I think it should be in the RFC
what the behavior is.

Another thing is the logic of setting global json error. Currently it just
reset the error value so the next call to json_last_error() will return 0
(no error) even though there was an error which is in the exception code. I
think that the behavior should be either not resetting the global error
value at all (the previous error should be kept) or setting the global
error value so the json_last_error returns the same value as exception code
or 0 if no error. Again it would be good to mention the behavior in the RFC
so we prevent a new discussion in the PR... :)

Cheers

Reply via email to