Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118486 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31438 invoked from network); 26 Aug 2022 06:53:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2022 06:53:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 627EB1804AA for ; Thu, 25 Aug 2022 23:53:02 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (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 23:53:01 -0700 (PDT) Received: by mail-vs1-f46.google.com with SMTP id q67so828042vsa.1 for ; Thu, 25 Aug 2022 23:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=g44Ep7Zsigcczk7dXNqcaGPwfgBprVK1Y99jctyYJXg=; b=aqmd63X0Ik1Q+gfwRLdpvIlz9NPuHJIVF2vbXJqTcUKoxcyuLJxn2YQrYWwhgDSEoi oHAcIoxU0IR+kdOXn2fWMFdceeyMfsg0EuWrUdwc89hhwiNiFToVkfBZq9k8/6asHfYg fe4SLUpUqqQKOuxP+3QwSzi/X8y7L8Y0toxS6k6SLvlmTPvIU4MTPrpJZ0mNgd0ZoeWA IuuMkdvOOFgLggM27klMhcFRMqrQ6j8uR3b759OvTZPzcKlLpyfIWDTMQh6c3bP5GILq Fb9edQKFXhy0o/OzXHSQqH7keGNta7LxVqBzAlAG/9fkfdLERjnmKIjNuh2W1py5Q8iO 0/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=g44Ep7Zsigcczk7dXNqcaGPwfgBprVK1Y99jctyYJXg=; b=CSg0sZ7iqN2uXrFskIJxu8HAwfsuKaK5+Zwyr6r/s5IFgHn3v423iimHvgaIVLU6vo TqnZ7N1VQrG+ZgWR/Ab7KVdMPJ8Kr6sI83lSIqULUGA5TD46Omm4bNmvVGnvCy1rflAr dE78QJq0NKjH2EwwRJb6+mxd2L+D0CjEcXhCz9GKcLPAd7eJqeIO9ZatG7OIt7xauMCD J0Ksrh2L618X7VP8GN2aSkxtcIBdzhXHPFa0VU3rDcGr1yWRW9GupijIG0eRo+tm3lbD snLheI36Zb0h+p62yUBvGiNheg4hPjnsQMx4pMpYdfjFtIIuKAbAyhK4PGsNiDYbNCxn v2iQ== X-Gm-Message-State: ACgBeo35ugfEWRnd8A6I1RstkOi3gYzpESuNp6ghyTTHzyrX5wm3hWC4 QyWQUj2TPC+JQSDX1nLow0oE1+VOGArAI38rZOc= X-Google-Smtp-Source: AA6agR7Wi/R6zpXdcSI1Pfb/gC4IIsWgeJQenoAhRcFN2Yad6vdaqUPNfn+GFzoERYFvQCBo22Nfx4Miz3gQ6M1TXjo= X-Received: by 2002:a05:6102:292c:b0:390:8bf5:7406 with SMTP id cz44-20020a056102292c00b003908bf57406mr2689907vsb.6.1661496781252; Thu, 25 Aug 2022 23:53:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 26 Aug 2022 08:52:50 +0200 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: dev.juan.morales@gmail.com (juan carlos morales) El vie, 26 ago 2022 a las 6:47, Micha=C5=82 Marcin Brzuchalski () escribi=C3=B3: > > > I share the same opinion you expressed here even though you admit in rece= nt email that you changed your mind. > > In recent versions we tend to accept more and more small standard library= functions with IMO questionable argumentation. The same goes here and I'm = not convinced we should introduce next small function that can be simply im= plemented in user land. Sorry but I dont think that a JSON parser with memory usage zero (or maybe a few bytes) can be simply done in the userland. This function (json_validate) is small by itself, but gives you access to the JSON parser. Can you please provide an example of what you commented? > Any example testing > 3MB JSON string are for me edge cases that normally= don't happen often to deserve special treatment. I don't agree with your definition of "edge case" here, as edge cases depend/belong on/to the system under analysis. By the way, the test case provided in the PR , "test 005" uses a json-string of about 3 MB (maybe 3.1) , and in order to decode it json_decode() needs something around 109 MB of memory. For me, validation can be done in a better and efficient way, like it has been probe with this proposal. > If we keep the tendency to pollute already bloated standard library with = an army of small functions that could have not exists and be replaced with = normal PHP counterparts IMHO we'll end with frustration from developers as = I believe DX slowly falls down here. Last but not least, I want to say that the function json_validate() is small, easy to maintain and extend if needed, and at the same gives us access to something that is not trivial to write in userland .... the existing JSON parser. RFC: https://wiki.php.net/rfc/json_validate Implementation: https://github.com/php/php-src/pull/9399