Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118310 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32687 invoked from network); 29 Jul 2022 12:28:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jul 2022 12:28:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C2BC51804B5 for ; Fri, 29 Jul 2022 07:26:48 -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-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 07:26:48 -0700 (PDT) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-31d85f82f0bso52821337b3.7 for ; Fri, 29 Jul 2022 07:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=BFUqI++3iraWrsluwURa9YYtCA7yr49iv+VXjOT8rpM=; b=N8oDvQxnafHyROGMh03HdWT6Y7Vg54ZHt4hnG15ljGRt40rzigSyh0Ifdzpkie6UyF uKl6GALuYEgGCmo6K2hdHt9DTWyNf9/nQ3dsQ1Lhn3ZvrDiAD1UW81vKXVFYDlkP7Ndv Ba+7AXKl69GNAqfmEdyx5Pn9YFkbCXKjS3njxsbdLHIYWBRgGTnYcPnjwMtaWol7BI9k m1PyjJNOkdJ7SgmxjSjP9FvrXNvyjNiZZrgKmBfw5iVle+ZMyOb10OheX8Yz+r+QrQh6 +yutb/g6EcZiIntWDd1vUcNSUrxxVaYf8Xu4+H7/QgWssl3zA77mEiLRyekFcUP4bIgx Aiug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BFUqI++3iraWrsluwURa9YYtCA7yr49iv+VXjOT8rpM=; b=NyeFtriLUgdrmJzthYgXwaUmu6qXQOVGIkdkzM8X9yUWxUvLo7bH0kv7qP4A8FjEIv tZKTK2Pe6Lsr1wIbYkPW80S8vjfuGgvPau1lldM3BqO8dxG8Ry2XPSGyeijf3V6jAuB3 +4rhenti3Xup2jlRZkhtmb6HxcyUajtb12Ci/IFXYMMQkjY0dXi0m+qrA+RiS9LKebMi ONsLNQ9sikn7NmRts9ZoIS1PdNATopiHKgaGFdFt598ET/bpdsF0JnCl1Rc+KPG1cooW ydwoQk2pDEywoGQXMegEzHcNJXe6dYtyD1KXkJyRRZ41+Q2xI2je4EaMVWBPJhswdTjz +8+A== X-Gm-Message-State: ACgBeo34a5FTGRgwkzu4ONaXGkl+X8nRmsnJKsBst7H+iGQjLGc94Z8T UR778dorAQWDj+yXSC27WTcgX4e8N5i16QYhOtCiwkn8FxNI8sb1 X-Google-Smtp-Source: AA6agR7uM+A7QpNhooBrHx927GPwnE9oLmzIjtJiZMquYZLQuNmtXYrv/TSxhY/tor7o8GE4cTBbJTnyH4B4jmla3L0= X-Received: by 2002:a81:3686:0:b0:31e:322a:f3af with SMTP id d128-20020a813686000000b0031e322af3afmr3145278ywa.497.1659104807748; Fri, 29 Jul 2022 07:26:47 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 29 Jul 2022 16:26:37 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000b6068005e4f27045" Subject: RFC Idea - is_json - looking for feedback From: dev.juan.morales@gmail.com (juan carlos morales) --000000000000b6068005e4f27045 Content-Type: text/plain; charset="UTF-8" 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. # Who would develop the RFC ? I would develop the RFC with the help of the community if needed. I already have a first version of the is_json() function tested and ready for review. Thanks in advance, I am looking forward to hear your opinion on this. Kind Regards, Juan Carlos Morales. --000000000000b6068005e4f27045--