Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119644 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22514 invoked from network); 1 Mar 2023 17:05:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Mar 2023 17:05:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 871F7180546 for ; Wed, 1 Mar 2023 09:05:18 -0800 (PST) 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 ; Wed, 1 Mar 2023 09:05:17 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 92CA05C017F for ; Wed, 1 Mar 2023 12:05:17 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Wed, 01 Mar 2023 12:05:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1677690317; x= 1677776717; bh=huwidAI/+uIq2c1D5S1/GHeZaVddVYVzvjIv9uiUSpo=; b=j Rn09dy5vZFq0V090X8lI/U0JGcQ3xWI/AnLnYdEEOzLW0jKMz9KOEHQg8cpPTrM3 BgbZm1qSuJGqJSgh57owZ5sYu5oOE2gZrryMSE4XC1gjaIJ8eGPJRmPL15Tj8mIC lRgW0ebsmTD89T48Zc4fYkBHEEL9VZNot9SLMMXIbZP1eVBfgU4p2Xh/VAwlbPUG Q3YFMhAlWmQHyq9iGuiitbZOEgRWM4y7mIsGRpzkUZ+MkUgydOsc+zgyYc3lrovK eRoGxCdw05x1B7GjDyi5ksuyoDnnSiNMeVBQOGZQck5VIRuci+z9QFLCY0oXAZkq mF6QVFwFDD8hOoQ/bVaCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1677690317; x=1677776717; bh=huwidAI/+uIq2c1D5S1/GHeZaVdd VYVzvjIv9uiUSpo=; b=RYlRTP4G76pDoP9JQQqyWDfIWUl4h9hlXA8sxv7u57vZ upQGQm4kn7R6naBkYWY+tWT9WK/FWcNQKCEd7oiDuWCjTSLYF2GEbsVCJ5/gWs1U B24VZrUEkqfx9NgFRr14RvaETkdmIF2PIYZ9ruvjENLIWXmTHswMa1KKQDQ+RNbm 9iWD5apNXgjOwiNx759eMIpi+heFbOG8ZFqi5538Tm6EcgMXw5RDWfF79AOGJnAe Q9nn/5dUKCcL5SxPRwWc71vj0nItaCQgH5YVvEO+2/cRc0hcFUBEmgXL11ez8KSP oevkc/s9DFA5nV2VvwdrIOaBrrB8y8aZvlMcyQ/G4Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudelhedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeekteelheffgeefvddufeeujeekhfdvtdeuuedvveet ieevheeludegjeduhffhteenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgr rhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3E9891700089; Wed, 1 Mar 2023 12:05:17 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-183-gbf7d00f500-fm-20230220.001-gbf7d00f5 Mime-Version: 1.0 Message-ID: <49d276f7-cfe9-4d9a-b225-9706986a4996@app.fastmail.com> In-Reply-To: References: Date: Wed, 01 Mar 2023 11:04:27 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] RFC Idea - json_validate() validate schema From: larry@garfieldtech.com ("Larry Garfield") On Wed, Mar 1, 2023, at 6:06 AM, Jakub Zelenka wrote: > On Wed, Mar 1, 2023 at 11:44 AM juan carlos morales < > dev.juan.morales@gmail.com> wrote: > >> Hello Internals. >> >> I am thinking about improving the json_validate() function developed >> for php 8.3. >> >> The actual descriptions goes like this: >> >> json_validate(string $json, int $depth = 512, int $flags = 0): bool >> >> I am thinking about enhancing this function to also be able to >> validate against a JSON SCHEMA, giving us something like this: >> >> json_validate(string $json, int $depth = 512, int $flags = 0, string >> $json_schema = null): bool >> >> so, if the string is a valid JSON and also respects the schema ... then >> TRUE. >> >> What do you think ? >> >> > I'm actually working on this. Currently developing the schema parsing in > pure C implementation in my play C tool called jso. You can see progress > here: https://github.com/bukka/jso/commits/next . The plan is to develop it > inside jso and then port it to jsond and then propose it for json ext > inclusion (that's how I developed the current parser). There is a lot of to > do as JsonSchema is quite complex (composition, JSON pointers, stream > integration for external pointers and more tricky bits) so this won't > likely be ready for 8.3 but should be ready for 8.4. I plan to introduce > some smaller things for 8.3 like better error reporting (error location > which I have already working in jso) and some other small additions. By the > way, the schema support won't be useful just for validation but also for > decoding and possibly encoding (sort of replacement for JsonSerializable). > Especially for decoding it can be further extended to allow class mapping. > We could also provide automatic generation of schema from class and support > attributes. I plan to propose all of this later as well but that might take > some time. > > Regards > > Jakub Ooo... This would be super userful, especially for some of the ideas I have floating about in the back of my head for new libraries. :-) I'm no help on the C implementation side but I'd be happy to collaborate on the user-space API design. That's something we'd want to get very-right the first time out, or else have just the primitives that allow us to do the not-slow bits in user-space. (Which will likely mean something more than just tacking an extra parameter onto json_validate().) --Larry Garfield