Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119632 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87545 invoked from network); 1 Mar 2023 12:07:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Mar 2023 12:07:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 84289180507 for ; Wed, 1 Mar 2023 04:07:01 -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 ; Wed, 1 Mar 2023 04:07:01 -0800 (PST) Received: by mail-ed1-f42.google.com with SMTP id eg37so52664164edb.12 for ; Wed, 01 Mar 2023 04:07:01 -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=RVFGxI6oDnqjpsN4Hm7TUazBPO40yTR6eaE/VOuaTmQ=; b=gh7MMsAt9N9p9km8L2GsFT9nfi62XA9GnqXJTiTjxP46uKMGGrDU4lhvoGif2nOLF8 vMyheZqv4dIqvN9/OA1YDdA1JlsJwqyt2vTkI0VB/+8jeiqCv/cn23MwRlJj/uetrjVi PPnVvdAcT1BGHvjKUxZsScWlLCoOUPY4AHYAFz4Sdee1Ot4W/r9V18MMBpAp+gNwbW4C 7ZccrunbiQdQ+zf+tkIxcbNHsZaV6aaGxvT3kaya5pff/aYtVdt0Qm3CJeDV6z8YiPoO pZieWw+28xPkKPIAOALW1D/x75zXWDtH1gXIeodblZosQjZDySIq25vuxA6HxQER+MIr BM0w== X-Gm-Message-State: AO0yUKVhljTpcONYTNWgazefP9AjUuai2mevd0Vq6i8d1Kbf09KNuakn gBck55XaE0w9szcn7cMNnPitHjncqxoAv4KvpX0= X-Google-Smtp-Source: AK7set9nootn9dMZzIzRyCtYJ6i4+TUVQZjnjNOT0Gv0ZJIUCqdnyU1H/E7R3ZJ62EjTyfZu+npzir3xxElB3MnJc7s= X-Received: by 2002:a50:9f4b:0:b0:4bc:5e2e:592 with SMTP id b69-20020a509f4b000000b004bc5e2e0592mr860897edf.7.1677672419728; Wed, 01 Mar 2023 04:06:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 1 Mar 2023 12:06:48 +0000 Message-ID: To: juan carlos morales Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000a0a0ba05f5d58cd8" Subject: Re: [PHP-DEV] RFC Idea - json_validate() validate schema From: bukka@php.net (Jakub Zelenka) --000000000000a0a0ba05f5d58cd8 Content-Type: text/plain; charset="UTF-8" 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 --000000000000a0a0ba05f5d58cd8--