Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118322 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23169 invoked from network); 30 Jul 2022 12:02:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jul 2022 12:02:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1B22C1804BC for ; Sat, 30 Jul 2022 07:01:28 -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-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.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 ; Sat, 30 Jul 2022 07:01:27 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id u1so738732lfq.4 for ; Sat, 30 Jul 2022 07:01:27 -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=fjkBePIrLUUpkHd14PV0NN+/kRotnMDvT6iMCXtZTGQ=; b=bi3HhYHfB3/dtQ4vhyrYrvTtljDbNO3sIaXOi2imdX2x4Y41bGYve6jxLpKT0J1UhL y+k/ob6AlvZVHd8TX5uTw/VMbF+/ALe03AsW+NJL/pAmzYj2slAyFrsN+Yai73G3Lbz0 m1VaxDIMwVsdEeWgkw/R8t1Ng51c4B5xFLFEOuHTdioJI0scwEviPvLIsqC1ZlSuZzmO 01wPluREWfZBn3lcw2zH+IhJhON/g5KjOqE5Cxc9lopAlmcJ9nzWo2wZdGG07irbL+Wi 9PMMg5qLsCiVc7riAgh2Hvppm4fJv71FN/PVSiZoaxt4dzLQc1wOF68dfVEDRMnw/q3s wDjw== 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=fjkBePIrLUUpkHd14PV0NN+/kRotnMDvT6iMCXtZTGQ=; b=AHNOlAMPlIDArsebf3LBBMBEVPiT6f0Zp9SzwJoOl3ixYclISFjT4oFuFYdkciIGRf DBOKi67Va0ixrbFoIUa9WJj/5UWnyzKiFHiT17HFG0x/R6P2s14Cur/YEKavotiJUFZa V2BmpU53c8eFJFjN6s6nZ52ny8ZsbHhG9XLpFTmQE+dS/83KcfvMfEGGv7WJC0rQYjAq NdyTrSyAULiA31v8D8HJJZD6iiaPIa/onxI4eNDObQf2VJwexy7SwrzafXCk21sG3z0X BqJ7IuLNc1gtYVe7BLL2tySPvyyJqDG2DgIXPeyq/zu4/ntWAKe6TBPoL4P0dpwJ3yJl uojA== X-Gm-Message-State: AJIora+4ugFDfQPVIV8Db3yavN8zwUVOtbI31RSrjxo6YC1ydVvhpu7O 8I5kYgIR24YDocPX+RhqT2xZuHRZlfQUpuf/fjNLGFgu X-Google-Smtp-Source: AGRyM1spnK0CvZksxOP2CzSVVjiRcHjc2m1jBamfOgygS41E0xAUSOh2oIQePI4IzlDEBRv6z8iXS9QRUACTjqTPphE= X-Received: by 2002:a05:6512:32c5:b0:48a:35be:8b47 with SMTP id f5-20020a05651232c500b0048a35be8b47mr2752352lfg.506.1659189685925; Sat, 30 Jul 2022 07:01:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 30 Jul 2022 16:01:09 +0200 Message-ID: To: juan carlos morales Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000d83b7505e5063382" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: nikita.ppv@gmail.com (Nikita Popov) --000000000000d83b7505e5063382 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 29, 2022 at 4:27 PM juan carlos morales < dev.juan.morales@gmail.com> wrote: > 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 string > 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 have > to execute the json_decode() function. > > The drawback about this, is that json_decode() generates an in memory an > object/array (depending on parameters) while parsing the string; this leads > to a memory usage that is not needed (because we use memory for creating > the object/array) and also can cause an error for reaching the memory-limit > of the php process. > > Sometimes we just need to know is the string is a valid json or not, and > nothing else. > > # Do we need something like this? If a check to an string is valid JSON > then for sure I will have to use it in my code either as an object or an > array. > > Well that is not true. There are plenty of cases where you just need to > check if a string is a valid json and that is it. Just looking into > stackoverflow will give you an idea about how many people is looking for > something like this in an efficient way. > Could you please give some specific examples where the proposed functionality would be useful? Regards, Nikita --000000000000d83b7505e5063382--