Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118315 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77815 invoked from network); 29 Jul 2022 23:51:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jul 2022 23:51:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E5F171804BC for ; Fri, 29 Jul 2022 18:50:19 -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-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) (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 18:50:19 -0700 (PDT) Received: by mail-vk1-f175.google.com with SMTP id w129so3062909vkg.10 for ; Fri, 29 Jul 2022 18:50:19 -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=d2BgnqLzchaqXrHC2Grbiuo5OS09eODZk2f55zbTUWE=; b=Lz4vGE4fy7bUqR/dd+r3yl42LS0IRBuprZ71x52u3OvzGhOCeee25u0ITy9GUS+KJo Dy/kfXbxDibS/2hAgUwjZxVy1KbxbHdNSdd5l60LGmgedO6Qgruv95L6FrVxS4WWE9uE 4RtdERwtCYSxRAN4E0l4SddDomIMWfPqlVtnJ5h7AiZzvpELwy1SDbs7T5dat+y/mCHR AhJX2hIr7k410eibw3UEdvAVRbyPxaxMyHSpTqN91lKVY/bC7fhh70Uu1vlRnkpo0LVR ovz35OEAtJ4e/19G0qiGekaU/rhaYVcDrpLDLz4/qa5PeiOz5tTpp3MLX4iXU+HXfiM8 7D1w== 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=d2BgnqLzchaqXrHC2Grbiuo5OS09eODZk2f55zbTUWE=; b=sDtkn/gn453A7G4ALVUyp9zPkPXGEOGKqoYUmrF7rcfY9Qd9uxPcxfzQjWf1bZJhWJ 3MZqGD9eWeEu7BD9dnLmr4Z5/F8wlYR4JZ+5S/GbanccjHczLfHd18Cj1ppG4lGcC3ju hQ739NQEs363X5ENKfh5v65pz1Eb+QkfrAH4y/crLoNbANPTEDumHHjszq+Py8miTyEN cVCH5GT4UeLs3aWDv8u8Fl1HyqEpOyKuHZ9hXvr7J57gve3udhPempAmylTcZikZj8DW OOz3Ggsn06jrA8U/wIPM9WPVM2/aBY9k9xss9EDeXpHqwfjccVIyvxMvMN4Gm0KjYPxS N3EQ== X-Gm-Message-State: AJIora889VuA48aw+QcbV1zcEK2bozYNnCTWLhYErQzC4K3QV3SiO0rl QaWfc/XnwyosW7bL7+r0b95D2zgC6YrViFNM6iU= X-Google-Smtp-Source: AGRyM1sw7xy+C9I/gcNecK1wx15XBMQxkt9YkSe3YSrxTX5PXLH/fCZSP8jrAW97CJIN2cHBbAppV/7RYd8PFEYh+Eo= X-Received: by 2002:a1f:2fc4:0:b0:374:bbbf:263c with SMTP id v187-20020a1f2fc4000000b00374bbbf263cmr2644298vkv.6.1659145818515; Fri, 29 Jul 2022 18:50:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 29 Jul 2022 18:50:08 -0700 Message-ID: To: juan carlos morales Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000024ac8d05e4fbfdd5" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: jordan.ledoux@gmail.com (Jordan LeDoux) --00000000000024ac8d05e4fbfdd5 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 29, 2022 at 7:27 AM juan carlos morales < dev.juan.morales@gmail.com> wrote: > # 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. > You say that you have a first-pass at the implementation done. I'd be curious to see it. My initial thought was that in order to validate the string, you likely need to allocate extra memory as part of the validation that depends on the string size. You'd definitely save the overhead of a ZVAL, but for such an object that overhead is likely negligible. So I guess my question would be: in the actual implementation that lands, how much memory would this actually save compared to json_decode()? This seems like it would make the RFC tricky, as the purported benefit of the RFC depends very tightly on the implementation that lands. Jordan --00000000000024ac8d05e4fbfdd5--