Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118474 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77983 invoked from network); 25 Aug 2022 20:45:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2022 20:45:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EA2F6180538 for ; Thu, 25 Aug 2022 13:45:38 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 25 Aug 2022 13:45:38 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id l33-20020a05600c1d2100b003a645240a95so3108169wms.1 for ; Thu, 25 Aug 2022 13:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=zYT9lTpQEwEcqGDtyIEYOWFe1HbztkwlZzDgCC0xT0A=; b=Vl3DGjyutps6nNlx43+mrB4v+rj9VczMCphYoBJ/r6/puX4xePhH4NyqL8pHMI6hy2 g3b1jZYJmY0Rhy9faEA+CTNiOd2mX1lUhGAQY7HN3AteWpgNep1tknhP/VMXec48I03P iSX0/+aR+F7YLXJJ6AnUl81IGMEOerMhz2E9VzLinMcWIIo2/zVb1Zg60gBu5KEoTupV aPMG74j5xFLzB1UKVJUOg14FE27x6xpB0WlSJOCsKFcUsPxp/wcmpmAgiqNKomqYdmxX NvhjN7Kiw3J/ObLNji8TrBe1zyuOAtuSFuEFXY7aD5nObFBqzxY9gsFG/dyrKctgR7/1 ARKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=zYT9lTpQEwEcqGDtyIEYOWFe1HbztkwlZzDgCC0xT0A=; b=wRFXQ8fSUIvRhk2m/rhLrGyftteUUnO0sBx3Xre0dGuzh4xT6GmWaF2BIFRoHqeaFF ldVMmj2Z2i2b3OnEqnoQB8hhS6A31G9LOD90g7bcA2tHuXlONypYcAkO+6Ct3jAJZzr1 /Zg7W7rJ9rpepQF2wnxGU4LANrSmOmuPeL2XmjOospqYy8U1M2Qw02XyGD2tXnnXflXX EdjwyD7wPbzyaFZcZBluihuojRVYei+vKHcZDvGGjK2k5JgTQ427/djTraEi6wgHEF1S DD/Mx0NflQU1qqAtT+7cCHGUrPQb6tLiup9gaN13+P3M6jw2TLKhB31TMlQVV4S4WdVs 5DJw== X-Gm-Message-State: ACgBeo33EEqNyNu+AZSmh+VcsdcthLGub9gUE9dyv/cF3Duq924kBjvc MHXeu6NDMrB8HB1qI+UrkckbqfoyIJQ= X-Google-Smtp-Source: AA6agR70oC2zHccHskfi1LhfqfrSI8NZOLxoiT9H+BSxER+4Ufbp9m1bB5fIhhiTyxvQsyA2012NXA== X-Received: by 2002:a05:600c:3541:b0:3a6:28e4:c458 with SMTP id i1-20020a05600c354100b003a628e4c458mr3382093wmq.188.1661460337472; Thu, 25 Aug 2022 13:45:37 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id l39-20020a05600c08a700b003a50924f1c0sm323811wmp.18.2022.08.25.13.45.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 13:45:36 -0700 (PDT) Message-ID: <30876360-1d4f-8097-0b58-fd902f1fa009@gmail.com> Date: Thu, 25 Aug 2022 21:45:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-GB To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: rowan.collins@gmail.com (Rowan Tommins) On 25/08/2022 17:02, juan carlos morales wrote: > I am glad to present to you the RFC for json_validate() function. > > RFC: https://wiki.php.net/rfc/json_validate Hi, Leaving aside the overall question of inclusion and looking at details, I'm not convinced JSON_THROW_ON_ERROR belongs here. With json_decode, throwing an exception is a useful feature because a) there is no natural value to signal an error, false and null both being valid results; and b) most code is written expecting the input to be valid, so failure is an "exceptional state" that needs to break out of normal flow. With json_validate, neither reason applies: there is no ambiguity in what false means, and no reason to write code that calls json_validate but doesn't check that return value. On a different note, I notice that several of your examples are not actually checking the validity of JSON at all, they are parsing it in order to re-serialize it - the Magento getJSONString, the Symfony getPrettyJson, and the humhub actionIndex functions are all directly using the output of json_decode, not just reporting whether it succeeded. There's still plenty of other examples that make your point, but those three should probably be removed. Regards, -- Rowan Tommins [IMSoP]