Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119652 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93009 invoked from network); 2 Mar 2023 12:38:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2023 12:38:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B160718054E for ; Thu, 2 Mar 2023 04:38:07 -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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 ; Thu, 2 Mar 2023 04:38:07 -0800 (PST) Received: by mail-ed1-f42.google.com with SMTP id u9so17509648edd.2 for ; Thu, 02 Mar 2023 04:38:07 -0800 (PST) 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:subject:date:message-id :reply-to; bh=uGyCb3l0o8VTGKScSNZUFXFhDf1EoYDdbPs+ZddHwdA=; b=X46s029hV7URhZL7XEG0c8jvfzolKDXpM8jgsQXRB4fok6GUi4Nv8hg7K8K5cjoFvR /QDdlGIotlepr+LTbE6GooyfGpcm0NzFwWYBeCcGnGBTaAFR4CGu8Bmdu28TsQPl7GMr yqMykmZtZWVunNAhzHY81DmkZxQmOzsA97kW2zxwEiRf5toLJHb/VHTI1XLeDPtPbNyu hmG0kQxgWHG+uk6dvYPoz03YLigq0H42pL/0E7Bn9Kp5gSuOT5Q/iOT8XMMHvPCTZJcZ dilJZadppPWielf0mqDf5ss4FS91vVD9ZRpPEx1u8UPP/feEuCcPPrQT0sXuL2sJoWSK gbZQ== X-Gm-Message-State: AO0yUKVxUC4AT/yiNgM5qNboXtLx+zSWMkGqNJJynLn+SonCR8KED+91 ahlYRSn4OiYCmwmfEJGW5hu8pHbqLs4TpCCbC8Ar8CttHzE= X-Google-Smtp-Source: AK7set8LtDFMm9VKEg2B83EaWsXek0iXAIHJm4KMRIp3+JALIDpm7jaw37QqnigvKnzL/+4w/Z5+NHflrrJIb6x465U= X-Received: by 2002:a50:ab11:0:b0:4c0:bc95:6088 with SMTP id s17-20020a50ab11000000b004c0bc956088mr773814edc.7.1677760685900; Thu, 02 Mar 2023 04:38:05 -0800 (PST) MIME-Version: 1.0 References: <49d276f7-cfe9-4d9a-b225-9706986a4996@app.fastmail.com> In-Reply-To: <49d276f7-cfe9-4d9a-b225-9706986a4996@app.fastmail.com> Date: Thu, 2 Mar 2023 12:37:54 +0000 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000b384da05f5ea19d6" Subject: Re: [PHP-DEV] RFC Idea - json_validate() validate schema From: bukka@php.net (Jakub Zelenka) --000000000000b384da05f5ea19d6 Content-Type: text/plain; charset="UTF-8" On Wed, Mar 1, 2023 at 5:05 PM Larry Garfield wrote: > 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().) > Agreed that we'd want to get it right the first time out so help with the API will be certainly appreciated. I will announce it here when I have got some draft version and we can go from there. Cheers Jakub --000000000000b384da05f5ea19d6--