Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118468 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65297 invoked from network); 25 Aug 2022 19:11:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2022 19:11:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1BD221804AA for ; Thu, 25 Aug 2022 12:11:58 -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.6 required=5.0 tests=BAYES_50,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-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 12:11:57 -0700 (PDT) Received: by mail-ed1-f50.google.com with SMTP id w10so15195087edc.3 for ; Thu, 25 Aug 2022 12:11:57 -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=B3yk/GPeKW7nq1MdEoEG5Y8iq6qmiX/dggJ7KFoAKCE=; b=gNlNMuQwXvB49KC8VP116InSgTh5s9i4DFs1iurQ7RM+oeqbmaC4ixrhcBGZl8kqxZ RZpnWS20AACTLPMIZuAmYzh5Zhi0i0Jm/i20DatECO4KbFLYfi9vyU3De7n1tOkXuApA roOLbB4rPJM1Hqq3eK7ugIDtZrpKdr096PpUTWRF+l5/Eptje0uDSdToZiRzxO7O27NI yJ9A1NlgjnEa05MPddTlPoTz4Mpx+K/8ukqmdZmYScOHQ43nMCaKJJAl+Q2wS4ScFNBW UCY/asburJguPcMHiCffn+lzVoNRpHbMMJKABNqB03mUnsLM9+licSwyVptA3mpjHmuc H5cw== 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=B3yk/GPeKW7nq1MdEoEG5Y8iq6qmiX/dggJ7KFoAKCE=; b=KuLqWadT0UUcR/zjO/Fx6X2+WBFkYUNvUn/Zy/fU/9wtaqgI1FI2CWNL89+H59+nMm ocwf+CgDy5Vex9KOgloCEMN8xxkpDK/znrXZiSNRZnjuvQD01Vz2Gr+1R61zEUqOPR4d XH9gYeg3gPM10cdYacnZKGG2ns8G56MVZhHPgZqmmDaMr5dVW08LlbTDcWnwqBxYl5Se 83Ptn47xnfXfOiufvO86b7uRd43nTrpXDB3y2TGxURvGbm9gBTVEOYziSgYElPt350eX ScKnBdv3kf2XiTE1GA7In5FAzyAzShI72GctpKoz4wu2gnGZUhkiRL5uHdTOp9UpRNf2 riHQ== X-Gm-Message-State: ACgBeo1IwgUydoGlZKiwlblXDgKruyF1vQBus0cSvLHumMCK/cE3uiTj dVyaTfRNxI5XX+TKEFOxX3wQwfcxyeXxEwraRUW3Ljmp6h8= X-Google-Smtp-Source: AA6agR6zVQ8eYhzH/pbsQI8oU2vvxC8XgGuTx/lvu6vquyn5cTHI0ARUGHx8bkGC5E91t2qN5R7/jiPMf8KowXye/VY= X-Received: by 2002:a05:6402:2549:b0:446:fdce:2a64 with SMTP id l9-20020a056402254900b00446fdce2a64mr4217871edb.288.1661454716276; Thu, 25 Aug 2022 12:11:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Aug 2022 20:11:45 +0100 Message-ID: To: juan carlos morales Cc: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000002c959305e7159286" Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: davidgebler@gmail.com (David Gebler) --0000000000002c959305e7159286 Content-Type: text/plain; charset="UTF-8" I'm not a voter on RFCs so my input may be largely irrelevant here but for discussion purposes: I remain unconvinced regarding the justification for this proposal. I'm not 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 for whatever memory and speed benefit the implementation of a new core ext_json 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 JSON 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 validate 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 is 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 function would be important to the system, whether anyone's encountered a scenario where this would have made a real difference to them. --0000000000002c959305e7159286--