Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118313 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56507 invoked from network); 29 Jul 2022 18:19:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jul 2022 18:19:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2B1B4180554 for ; Fri, 29 Jul 2022 13:17:57 -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.7 required=5.0 tests=BAYES_05,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-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 ; Fri, 29 Jul 2022 13:17:53 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id w15so8841577lft.11 for ; Fri, 29 Jul 2022 13:17:53 -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; bh=mABVJUinaalNVTrKc0fhOaQ1VdSsxnHi2FQLwUMqaMQ=; b=pnCfm7Kzu0vpGCYFIhrDmtOrmd5NYCV/kSLgECNW42McqfJkmPKwVSUKggMvOX0p3w XI5SAcQgA8zZDQTjQCgGrMoO8Z+H5fNtPR8M+Aulf8g2iA27nlCAKcqia3w92RM9MVfj aRNZefA7izoo8AlJvV1efSyQMBoe4hBh+3RvoG5+npJSIgyu/SGxSk8Pz+oPNLp6jSKG RVQD6ev4b8D95Pp5IPO4AhXrNaLZwVsHi4A9dXiBTgWg2Ibtz/bKcYbrNUZ09QdJLHru Qe75dt0fV1XAH6masCiH12J2FWKigLssAb3FYq9hg8GlJLc7yklIHoF+Yzw7k3n6PTCk niLw== 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; bh=mABVJUinaalNVTrKc0fhOaQ1VdSsxnHi2FQLwUMqaMQ=; b=QbLSWGgTbwP12nnFOhHNbN8PxAxTnOOkDmpiXMMmtPvAG+1xzZQ/TGOj0ktjfsU6XB YEbpy6VoGznb8Dhk/u8Cz1SbtgvSpCR8jw5o9pwj1iRcCVPpKMw9w1CEf6VHeEm3M9tm HnTbydYkopaRe5Ls6lAOOLfUKjwaezA5cih0BQ2T0M2nVQfxFFHvizmcrC4hSo7m2HFY m9MTHluAj6Nouy4at3RPfEjWs9kFlWTm3OCe2C9l7x96OZTCAzQjy8At5Opr/Lmac9jD iXZdx3BwWlk+abxhIpaL47JeiESLbsAssBAty1A9A5JUA6DAzbX8VbIJ4HssxDguH9T+ u6OQ== X-Gm-Message-State: ACgBeo17Cphz262uTSsl+/21p7I5eyW9T1LSqGTuAIVKUxilWsnkxdeN i+LbcFE99zJmYqy0/d4RoI91JKKWcka2fbL6XrYDNCsGCqU= X-Google-Smtp-Source: AA6agR6p4fCXLeTV9Lm6WZc4oqgNjcr1Jib3I5NUkuBH7bpeX2fgzpQAG/64ga+GKKJVm9zjZyMnXKtZM6zSSuW3JQo= X-Received: by 2002:a19:c51a:0:b0:48a:e938:c728 with SMTP id w26-20020a19c51a000000b0048ae938c728mr51412lfe.592.1659125871744; Fri, 29 Jul 2022 13:17:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 29 Jul 2022 17:17:39 -0300 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000391c2c05e4f75816" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: david.proweb@gmail.com (David Rodrigues) --000000000000391c2c05e4f75816 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I was about to say NO, but after being completely your argument, the idea makes sense. Initially I thought about using json_decode() with error capture, but the idea that it would overload memory makes perfect sense, compared to a simple structure analysis, if that is indeed the user's intention. The performance would also be absurdly better. What worries me above is the misuse of the function, like checking if is_json() =3D=3D=3D true and using json_decode() right after. However, I be= lieve this can be easily optimized by the engine itself. My vote is YES. Atenciosamente, David Rodrigues Em sex., 29 de jul. de 2022 =C3=A0s 16:32, Micha=C5=82 Marcin Brzuchalski < michal.brzuchalski@gmail.com> escreveu: > Hi Juan, > > pt., 29 lip 2022, 16:26 u=C5=BCytkownik juan carlos morales < > dev.juan.morales@gmail.com> napisa=C5=82: > > > I am following the RFC guideline for the first time. ( > > https://wiki.php.net/rfc/howto) > > > > As suggested there, I am here to get a feeling from you, regarding the > > following RFC for PHP. > > > > # Change (draft): > > > > New function in php called like: > > > > is_json(string $string): bool > > > > ## Description > > ### Parameters > > string $string -> string to find out if is a valid JSON or not > > > > ### Return > > Returns a bool. The function is capable to determine if the passed stri= ng > > is a valid JSON (true) or not (false). > > > > # Why this function ? > > > > At the moment the only way to determine if a JSON-string is valid we ha= ve > > to execute the json_decode() function. > > > > The drawback about this, is that json_decode() generates an in memory a= n > > object/array (depending on parameters) while parsing the string; this > leads > > to a memory usage that is not needed (because we use memory for creatin= g > > the object/array) and also can cause an error for reaching the > memory-limit > > of the php process. > > > > Personally I'd vote NO. > > Cheers, > Micha=C5=82 Marcin Brzuchalski > > > > --000000000000391c2c05e4f75816--