Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118484 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21530 invoked from network); 26 Aug 2022 04:47:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2022 04:47:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1D0091804AB for ; Thu, 25 Aug 2022 21:47:56 -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,HTML_MESSAGE, 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 21:47:55 -0700 (PDT) Received: by mail-vs1-f46.google.com with SMTP id o123so637069vsc.3 for ; Thu, 25 Aug 2022 21:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=C8lliKmOdZN3/3Sps1ZGnj9WcamAlgRD8h4LrAvKpbQ=; b=Kp42UIeRQP3bPYVK14i7nOJalu++aQJTbClGklHoLRziAefHDSsxTFWWQUpWxAu2PG xY1kwKuW6ItrhAaZ3Q4e1PXEK/ixEd2SKCFr4ugeU7L7qhhcsVfqYA0XccDaisCs3+mZ hTnvjgb30FgVHYfikQRDVfTOllp7iQTAqhosEpF1ncSDxNa17qnxAT6YvCMCYlLbIiRr +ZzcGFyrdAs5AxCMQj9VlqSPJ1dhd3ufdzWnMkO42Kowy8McG2Z/w7Gc1WoQiqeVZg3B Y6FigWZvdA1x0W7bEvwKsR4BXPMKN6sNdUXttA3jOhV8vod4wBDUaVIRPijUsohPd9Mj p23A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=C8lliKmOdZN3/3Sps1ZGnj9WcamAlgRD8h4LrAvKpbQ=; b=nckDATXhz7nQkiBKyLl1Bjguik2+6BjpYvu6BTDgt3g62OKydEyogzV0E90//xkw/c lvAsB5Xa8ZK+Sldrs41zTKYYtAiFRvRjEwFEpckYDCBWbvOcrx25e8hO3SkOzw0fA0dN G7YbEq9xlzGjqw4fyrlMn64v3d+0TWju7MSEFACEpd8lxhF8/6P3gFNIbk5XMLNT0U4w W/j99DlIRyOiruupJpBXNOilq67BbX/hBVGGVvwJcm8DK/AJ6J2yLQaiy6bVi4wVXdpb ZRaQrI+Mr+ktgn2e0P6Wo153W+y86foZ1I1Dns0fqNDyCEACIXe641jUc8ynFjnFI+CH S7Ug== X-Gm-Message-State: ACgBeo1Nuv+SxAnF/DIN6uivv0X0/MvvpzJeFbtOWRGtiuIIsNMslEbN jx/C9uE/eV8dO/y1PvcSDjRVT4I/AmLQoXA5haQ= X-Google-Smtp-Source: AA6agR4e+V9ESQNzWMRjmJ90SnEUNM/4lmnriBQ0z6JbFhOS4P2m/bLm6dKLUAjf2XsTo+UMW4aJQ4yZ3MbFdJIitr0= X-Received: by 2002:a05:6102:512b:b0:387:cc8f:a0fa with SMTP id bm43-20020a056102512b00b00387cc8fa0famr2673600vsb.3.1661489274942; Thu, 25 Aug 2022 21:47:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 26 Aug 2022 06:47:45 +0200 Message-ID: To: David Gebler Cc: juan carlos morales , PHP Internals List Content-Type: multipart/alternative; boundary="00000000000007f98505e71d9e06" Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --00000000000007f98505e71d9e06 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable czw., 25 sie 2022, 21:12 u=C5=BCytkownik David Gebler napisa=C5=82: > I'm not a voter on RFCs so my input may be largely irrelevant here but fo= r > discussion purposes: > > I remain unconvinced regarding the justification for this proposal. I'm n= ot > saying there's a strong reason to NOT implement it, but I'm not convinced > it's really going to be a significant benefit to many people at all. > > I agree that the number of userland implementations for a "is_valid_json" > type function including in some widely used frameworks and systems > indicates there's some degree of demand in the ecosystem for validating a > JSON string. > > But the more salient question is whether there is a significant demand fo= r > whatever memory and speed benefit the implementation of a new core ext_js= on > function delivers; that is, has it been established that the use of > json_decode or common userland solutions are in practice not good enough? > > There are many examples of userland code which could be faster and more > memory efficient if they were written in C and compiled in, so the mere > fact this proposal may introduce a somewhat faster way of validating a JS= ON > string over decoding it is not necessarily a sufficient reason to include > it. > > Are there are examples of raising issues for frameworks or systems saying > they need to validate some JSON but the only existing solutions available > to them are causing memory limit errors, or taking too long? The Stack > Overflow question linked on the RFC says "I need a really, really fast > method of checking if a string is JSON or not." > > "Really, really fast" is subjective. No context or further information is > given about what that person would regard as an acceptable time to valida= te > what size blob of valid or invalid JSON, or why. Indeed that same page > offers a userland solution based around only going to json_decode if some > other much simpler checks on the input are indeterminate for validation > purposes. Haven't tested it personally but no doubt in the vast majority = of > cases it is sufficiently performant. > > In most real world use cases [that I've encountered over the years] JSON > blobs tend to be quite small. I have dealt with much, much larger JSON > blobs, up to a few hundred MB, and in those cases I've used a streaming > parser. If you're talking about JSON that size, a streaming parser is the > only realistic answer - you probably don't want to drop a 300MB string in > to this RFC's new function either, if performance and memory efficiency i= s > your concern. > > So I'm curious as to whether a real world example can be given where the > efficiency difference between json_decode and a new json_validate functio= n > would be important to the system, whether anyone's encountered a scenario > where this would have made a real difference to them. > I share the same opinion you expressed here even though you admit in recent 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 implemented in user land. Any example testing > 3MB JSON string are for me edge cases that normally don't happen often to deserve special treatment. 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. Cheers, Micha=C5=82 Marcin Brzuchalski > --00000000000007f98505e71d9e06--