Re: json_encode() / json_decode() warnings
| From: | Andrea Faulds | 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 internals+get-100103@lists.php.net to get a copy of this message | ||
Hi Duncan,
Craig Duncan wrote:
On 27 July 2017 at 16:57, Niklas Keller <me@kelunik.com> wrote:Could we not simply make it a flag? e.g.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
$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/