Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84430 invoked from network); 27 Jul 2017 15:41:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jul 2017 15:41:28 -0000 Authentication-Results: pb1.pair.com header.from=php@duncanc.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@duncanc.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain duncanc.co.uk from 209.85.220.171 cause and error) X-PHP-List-Original-Sender: php@duncanc.co.uk X-Host-Fingerprint: 209.85.220.171 mail-qk0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:35415] helo=mail-qk0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/B0-10671-7A90A795 for ; Thu, 27 Jul 2017 11:41:28 -0400 Received: by mail-qk0-f171.google.com with SMTP id d145so98567922qkc.2 for ; Thu, 27 Jul 2017 08:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duncanc-co-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=s/sbiuzRMVvaRHQw+lL0nlgjs6bwRBiVUA09pgdgEfs=; b=exXOTNVsfOTdNpAqceCVui3IQaqCNPoRFTeEXKPtS6yxNwaXg9HrmRb53t48IKqAdb v/zgVTRg1bRxPhQyuWtibvnRSYDQWpW38rbaVmN1Gl9gtmqjIO7obOTWf5zagDiSC+0c DHffbkI7+VTdTqSp4oNGU0jgZrFouJOgGmlDolhP6XsZlVYWjytLcObjBR5ex1XUk7QK NAIFZORraczaOIsvb4bC5jeU2h2dgiPfmz+XonQwcDDt2NxraWi5wEXvxozZKjSHBHg+ 1CRAYMz3r4hDvGJKCbhVkBRKA125Cik3WlPPTxCaA+V395rrrXLKnPk8K7A72RwZjIVm 75mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=s/sbiuzRMVvaRHQw+lL0nlgjs6bwRBiVUA09pgdgEfs=; b=EKwpadFp+Jph2mc+QiFfhjofIHYuu2BCSg3KiQ+8Uuli4hRY7LpjRplNFOn4bTI3nY Ki+j92xDOaehn5pd/hSyr+3o0p6rOnJeVdujnc2e3+wwr9UVfoUWcibiF4nv2miTlnxw MbBcW9AYdMo23dbc3hT2rF4MPaLg2hTqYfe9eU7QC0eC8wUmgHpAy6OASqQv32FuAZGU rakqgHUzDNjWUSv7grjIafLsHbCGAtXpjUI94C+QomrpsXN8SNBe1jxhgyJloEY0gINh YFi0KlK2SsJheLrAcXit+b/BHdNvTgugrogzbPVBw0RrNmKhFWRKSOEp6woAs5KrXe32 j//w== X-Gm-Message-State: AIVw110gM1rBwtOeiHyAzl9de3yoIQxZdD8ULtIU2HBhSpSJwTwGMxVF Eam5vwH/Qo+AshpY3NY= X-Received: by 10.55.64.81 with SMTP id n78mr6039172qka.36.1501170084839; Thu, 27 Jul 2017 08:41:24 -0700 (PDT) Received: from mail-qt0-f179.google.com (mail-qt0-f179.google.com. [209.85.216.179]) by smtp.gmail.com with ESMTPSA id z192sm13395968qka.46.2017.07.27.08.41.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jul 2017 08:41:23 -0700 (PDT) Received: by mail-qt0-f179.google.com with SMTP id t37so69469647qtg.5 for ; Thu, 27 Jul 2017 08:41:23 -0700 (PDT) X-Received: by 10.200.42.117 with SMTP id l50mr6273757qtl.210.1501170082632; Thu, 27 Jul 2017 08:41:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.21.139 with HTTP; Thu, 27 Jul 2017 08:41:22 -0700 (PDT) X-Originating-IP: [195.99.194.20] Date: Thu, 27 Jul 2017 16:41:22 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Internals Content-Type: multipart/alternative; boundary="001a113f417685eac905554e651f" Subject: json_encode() / json_decode() warnings From: php@duncanc.co.uk (Craig Duncan) --001a113f417685eac905554e651f Content-Type: text/plain; charset="UTF-8" Hi internals, When using `json_encode()` and `json_decode()` it is required that you manually check for errors after every call, eg: ```php $data = json_decode("false"); if (json_last_error() !== JSON_ERROR_NONE) { throw new UnexpectedValueException(json_last_error_msg()); } ``` This isn't _that_ unusual in PHP, however normally in these situations a warning would be raised. But the JSON functions only raise warnings in a couple of scenarios, most issues are completely silent. I wanted to begin a discussion around changing this, so that warnings are raised for any issues during `json_encode()` and `json_decode()`. I have an implementation ready and I'm happy to draft an RFC if this suggestion doesn't receive universal hatred. Thanks for your time, Craig --001a113f417685eac905554e651f--