Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119649 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78809 invoked from network); 2 Mar 2023 09:00:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2023 09:00:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 99D31180507 for ; Thu, 2 Mar 2023 01:00:57 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 ; Thu, 2 Mar 2023 01:00:57 -0800 (PST) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-536bf92b55cso414453747b3.12 for ; Thu, 02 Mar 2023 01:00:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677747657; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oEMjcVji+zmE3o+2u1NbWHTr+ibCSsFsrqfyuHghH7k=; b=fQFQvh4LaXY59yqgH/Drn+aCc67c+LSsPotLJe+MkZDTj3E4sBz0GCGU0yuFNCTuue qSqVNsJ5f7SlZrX+irXKlBptN57ksn94aTFjBWXgwZcwZt97LifAsvk249QnXHQvXzVK rxseleQYUpFaZuHrNSkr2qL/TX+X7YwUkoP4P720su7AFhTOL9Fryop9pW4hFYaOSPEN uQoYdywxHgk4WwG78Qb4ZRJSjB9afGbNbsFtUmde1ckz9IPaPiwgFdW+52mqhmOYh5sn n4IaZfLiyCQtzbdWpFnsOqPG9LXlUVkfYBT56enp0nxU/eRIdU8118y+nbNjqiC9W6ZS fzNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677747657; h=content-transfer-encoding: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=oEMjcVji+zmE3o+2u1NbWHTr+ibCSsFsrqfyuHghH7k=; b=7Cl/IcsuvELYrgATNuhqEqgS48Md3Cq5bTEq2eCRI62tnMdL2BCftMvSUq9J6stB4z tbQ2qoiHlkw6bEX/yxT9tq66ZvUZpZ593hqZuBrFTGqpRwQXVk8qw2VL/BrGrccIVlcI 6VSunC807ZPqDh467WPBD+w/8SoybY8OhVyzPS9LKdpni1ndvok2O1xFKVOfr5MU3Y3j VUSWGAbOz5sXzdbgvOJFSE2BfMTkJcEmgZzYeawczbQf1eI0YARr2v9DXrufcm21f75y MYR/8IxE3HDfuafxpnKq0FjfKp6uWmo4HzqEatCpKf5aplWAiCr/XYyJGYq/uecA8E7p i4VA== X-Gm-Message-State: AO0yUKUw39zVL9qQ3ZOH+e0IdQD5M7/XlME7Zyy09n0G9Z0eUGDIVDvL qRaVkswovm0/7ZNW6VfwdjhrWSnTGuqT9ZhnCx5G8cgDHlCdtQTF X-Google-Smtp-Source: AK7set9MidWpcCBT+YAah0ImBBOR1qE1yUnn/p/DnWL8DhGdsXDSzBBjfz+sDI3HkGgwuh2E5995De6Lm6+vpGxyGlc= X-Received: by 2002:a81:b603:0:b0:533:9b00:dd0b with SMTP id u3-20020a81b603000000b005339b00dd0bmr5959005ywh.2.1677747656932; Thu, 02 Mar 2023 01:00:56 -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 10:00:45 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC Idea - json_validate() validate schema From: landers.robert@gmail.com (Robert Landers) On Wed, Mar 1, 2023 at 6:05=E2=80=AFPM 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 =3D 512, int $flags =3D 0): boo= l > >> > >> 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 =3D 512, int $flags =3D 0, stri= ng > >> $json_schema =3D null): bool > >> > >> so, if the string is a valid JSON and also respects the schema ... the= n > >> TRUE. > >> > >> What do you think ? > >> > >> > > I'm actually working on this. Currently developing the schema parsing i= n > > pure C implementation in my play C tool called jso. You can see progres= s > > here: https://github.com/bukka/jso/commits/next . The plan is to develo= p 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 o= f 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 introduc= e > > 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 fo= r > > decoding and possibly encoding (sort of replacement for JsonSerializabl= e). > > Especially for decoding it can be further extended to allow class mappi= ng. > > We could also provide automatic generation of schema from class and sup= port > > 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 h= ave floating about in the back of my head for new libraries. :-) I'm no he= lp 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 tack= ing an extra parameter onto json_validate().) > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Hi internals, > wish one day we could have something as simple and ubiquitous as Composer installing PHP extensions When it comes to Docker containers and PHP, I've found https://github.com/mlocati/docker-php-extension-installer to be invaluable. I wish it were part of the official Docker image because it is so incredibly painless. Usually, there's even support to apply upstream patches and get extensions working in later versions of PHP (for example, Memcached and PHP 8+) before they are officially released.