Re: json_encode() / json_decode() warnings

From: Date: Sat, 29 Jul 2017 14:16:09 +0000
Subject: Re: json_encode() / json_decode() warnings
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Duncan,

Craig Duncan wrote:
On 27 July 2017 at 16:57, Niklas Keller <[email protected]> wrote:
It should rather just throw exceptions. Warnings do not really allow error handling, they just allow error reporting.
Agreed, but I can't see Exceptions passing the vote. Warnings can be silenced by those that don't care and converted to Exceptions by those that do
Could we not simply make it a flag? e.g.
    $bar = json_encode($foo, JSON_THROW_EXCEPTIONS);
    $baz = json_decode($bar, false, 512, JSON_THROW_EXCEPTIONS);
That wouldn't break backwards-compatibility, but would still provide the desired functionality. :) -- Andrea Faulds https://ajf.me/

Thread (14 messages)

« previous php.internals (#100103) next »