Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118331 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6144 invoked from network); 31 Jul 2022 16:23:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Jul 2022 16:23:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22467180539 for ; Sun, 31 Jul 2022 11:23:01 -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,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-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) (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 ; Sun, 31 Jul 2022 11:23:00 -0700 (PDT) Received: by mail-vs1-f47.google.com with SMTP id 129so9166071vsq.8 for ; Sun, 31 Jul 2022 11:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Pxzd9Y+Ift3xjcNvUS14vVTQzMQT3IQ8fkLmydrYKtk=; b=eg0Z/p8Vp5ozr1omvR40I281RmgGB4hhLxcOoI3YVTWrnXiJab3IpVjWaiPeuGK9bM qDHEDxM9M71HBx38ybauqlqDdNyLpVG2aeiWoCOzdkplv1zR2jSQ7QK90/EeSwsSUD8E BfykBD+BAZ2v8zdsxp3wT6+fQf+kxpBan8jd9G1WPOu45kgif6UNobH3+BgzeaiEYlFk dr6D3FUwO6l2Gj57FJxyvf2OEFqkwK6LnUUFufzPiEaEHeGTrJO7gbBEbYVBY5unkg4S ZxeMC1mXcMR+wbq4ennpXo/g5IILR7+eSgA94F6CJZwTg69nfVhZ+6ARfMNuUTWYP5WE p6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Pxzd9Y+Ift3xjcNvUS14vVTQzMQT3IQ8fkLmydrYKtk=; b=EC9unbcuQUCRYekmgf7xEjPaRKSnsHxOQJoaVjro41/bcuyNKdzALEc7BTwTlEhwpC Xh2Vp7VnLHzJTHKiHOXQhDEMJYGW60/idFgYX3cyB7ajtS1EnheGqf6J6I4iIL01tNQ6 9P2HxdDlMn7hiH1shrjIUka1+AGfoDQydUDlQH3Y6wxe6261rtjL2PS8OG86PgIKy4zz /bbTOYLbPbbWMLUMGrvavAOcU8ElmG70jKrNyTMAbc87gUtaNQTFDGUDAdXZ3U1zg11f Pthv51cbSKkLykBeeosnQQ5sEPLzf7I2wPPH37Wdpt+DQ7BsE6DCk+JaA/IwGfNC2J2W jkow== X-Gm-Message-State: ACgBeo2ILOepTfUHalYBZwBszIUkzB4IDN//IqIIlnc7Bjp/cnY01nLn lqi/IgKRmx74XyIIVoetVqrSdNbexnFW54JT/VY= X-Google-Smtp-Source: AA6agR7HXrxsQQCFyP6xv3EZXjXJ9Hj3UyD1Wwg6Gh62avmzSAs/WOcZcp1G/a04+uWV6D2vnLePtMnNEba/zm0gu8o= X-Received: by 2002:a67:d314:0:b0:36e:fbed:361a with SMTP id a20-20020a67d314000000b0036efbed361amr3368227vsj.17.1659291780125; Sun, 31 Jul 2022 11:23:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 31 Jul 2022 20:22:49 +0200 Message-ID: To: Larry Garfield Cc: php internals , Nikita Popov Content-Type: multipart/alternative; boundary="00000000000022193305e51df94c" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: dev.juan.morales@gmail.com (juan carlos morales) --00000000000022193305e51df94c Content-Type: text/plain; charset="UTF-8" (I received an email from MAILER-DAEMON@lists.php.net , I had to cut the message history as the mail server complained because the email got too long) Larry, here is the same benchmark including memory_get_peak_usage as requested (more after the benchmark) ----- Benchmark including memory_get_peak_usage ----- # json_decode() Megas used before call: 79.23828125 PEAK Megas used before call: 128.00390625 //<---- Megas used after call: 3269.23828125 PEAK Megas used after call: 3309.23828125 //<---- Difference: 3190 PEAK Difference: 3181.234375 //<----- Time: 12.109144926071 seconds # is_json() Megas used before call: 79.23828125 PEAK Megas used before call: 128.00390625 //<---- Megas used after call: 79.23828125 PEAK Megas used after call: 128.00390625 //<---- Difference: 0 PEAK Difference: 0 //<----- Time: 5.4504480361938 seconds I want to clarify, as I previously mentioned, I did not develop any parser at all, the parser already exists in PHP and is use by json_decode(), in short words , what I propose is to create a new function, as an interface to THE EXISTING PARSER, only, and only, to check if a string is a valid json-string or not. I already provided a lot, but a lot of real usages of this, and at the moment the only way to do it (without using any 3rd package) is by using json_decode() , and the drawback is that json_decode() generates an object/array while parsing the string provided affecting the memory associated with the php process; and sometimes you just need to check if an string is valid json-string or not and nothing else; I have provided code from major open-source projects, and also THE question in stack overflow, which is viewed near 500k times, which indicates somehow the number of users interested in something like this. And yes, we can use a 3rd party package, but in companies, using a 3rd party package is not that simple, believe me. ------------ Regarding publishing the a PR with my implementation, is out of context at the moment, because we are discussing if a functionality like this should be included or not, and nothing else. Also I am pretty sure that if this gets a YES from the community (so far seems so), and I show my implementation, someone will tell me that it could be done in a different way , and is totally fine, is great actually. But now, at this moment, everything is about the functionality. ------------- I also want you to know that I really, really appreciate the time you took to participate on this and being direct and honest ..... THANKS A LOT (I really mean it). ============== People I have made my best effort providing you all with as much information and answers as possible. At the end is up to the community, if YES ... great , if NO ... great anyway, it has being a beautiful trip so far, but I cannot lie to you, I would really like to see whats next. I send you all my best wishes. Juan > --00000000000022193305e51df94c--