Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127886 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 2BE021A00BC for ; Fri, 4 Jul 2025 22:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751666987; bh=QwSvVwHtbKmPP8MQP+QtpODrmzp+qrDtDUnyrDaKSXM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=A4hVr74eGwu9to9Qp7hwaGgd+D55pZry6iK0NP8tssbJyqhdygcFLDwoS44r7NrRy qufe6E7SWYOBRbwXzwulVKclR6zg0VY5Pkdh6eCx+M3ce+b3SV3KjZpklqhtnQ1fUp 5VR9N/kN4Z1f0229+URNoHiYJbRvwNvK/sJN+7WtDeufzjBZRa/zTYJ4GNCQf/fSxr 76tl1ji1FOKAloznFX60eTsJv2ENoWvcCfATzfc4FDBDwA59FDwT2Zvc3t1HRovNf1 0W4MwOy4GH8WEW2+trcz/Q6pllrcz7X7z+9HZ59pJlk8pk+WiMM95+rSOW9IzXpwTF Mu1+GSU/OEtyA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E81D180507 for ; Fri, 4 Jul 2025 22:09:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_40,DMARC_NONE, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 4 Jul 2025 22:09:46 +0000 (UTC) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-40b32b6af9eso799060b6e.1 for ; Fri, 04 Jul 2025 15:11:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751667097; x=1752271897; 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=QwSvVwHtbKmPP8MQP+QtpODrmzp+qrDtDUnyrDaKSXM=; b=ecJ+vrb5YpQ3UEJJWEYV7jEjYbq+LEYPLEuCRFNf0nYqJcdn9hMfwpQ2ghhDKOU5Sj AwzwaJxfcEi9lPToXU6o3sYpbobnW9TTECc1f+SgCjGYgiXyou43+L2YC5hOzC0hNrEr 2h1bdLxWcvagUVTdDrwijOU5TmUkGinpan26xIMJaVVpgUx8pCeJ81QdvOKqET/BbW3f 98pXYzAQL1NPyzFnVI0FkX/SR0n5R7NscUXVlioUbuffOydugWuCfS3vnTITbmDB7fBC 1fwzKg89pQenwb4wMF62ZSQJx56kJ0tV8IN2qtB9nFY84Db1Dz7BPIk6652QYnFqRYEl F/nw== X-Gm-Message-State: AOJu0Yz0LF+eWmIte2TieZYfiySvg4BZT6uWSF9oP8jfYuweoZbgK31l MtHMPu7OeA1dgU89K+LKbyqwzT2tpuqYTll8Jei3VeJXkvlgLQii/hiXgb11XL2VFYuynomsLTg UsHfxS6WiWVe4jvMWKMJGUsVz5Z8Ww1M= X-Gm-Gg: ASbGncsD7A2grJJ5EcYCKc6q6VPyFjTSFdLgQiXoTLamKl2PvRg1Y7Ce0P95thrSoJX tbaPkteE/rCvc0vcGp4pBgM4wYoTNNKnvbQ50HoEBEZmO+AQzEH7CaWYA5mUnjUpY4PgdROPr1V biQ9OQ3EwLiQw29iPIRZfOhYclAIUESSs5X40X5cf1qGY= X-Google-Smtp-Source: AGHT+IHSdszGW1FNnqm2ukytL5+5eDupinQEmbB2fdXIIkuLYnXxxY66/Db00SRVK5/nEx3DRzqDSiQBkBbfmbENT1E= X-Received: by 2002:a05:6808:18a4:b0:40a:fb27:9e8d with SMTP id 5614622812f47-40d2bd58ee3mr214507b6e.15.1751667097305; Fri, 04 Jul 2025 15:11:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 5 Jul 2025 00:11:25 +0200 X-Gm-Features: Ac12FXyixUWnq0Uc1PQOxqjPvGwaHsem1t3x2aSQl5lDyqWukmrpw1SmqLQ_nNM Message-ID: Subject: Re: [PHP-DEV] [RFC] JSON Schema validation support To: Valentin Udaltsov Cc: PHP internals list Content-Type: multipart/alternative; boundary="000000000000198810063921c7eb" From: bukka@php.net (Jakub Zelenka) --000000000000198810063921c7eb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Fri, Jul 4, 2025 at 11:49=E2=80=AFPM Valentin Udaltsov < udaltsov.valentin@gmail.com> wrote: > On Sta, 5 July 2025=E2=80=AFat 00:04, Jakub Zelenka wrote= : > >> Hello, >> >> I would like introduce and open discussion for RFC proposing the additio= n >> of JSON Schema validation support to JSON extension: >> >> https://wiki.php.net/rfc/json_schema_validation >> >> If this is successful, it should be just the first for further >> improvements (see the future scope). >> >> Kind regards, >> >> Jakub >> > > Hi, Jakub! > > I like the idea. I have a couple of initial thoughts: > > 1. Wouldn't it make sense to place all the new classes under the `Json` > namespace, similar to how it=E2=80=99s done in `ext-random`? > This would be widely inconsistent with the current interface / exception class in the extension. The ext-random was a new extension so it's a completely different case. I think it makes much more sense to keep the extension consistent than introducing new interface. > 2. If there=E2=80=99s no way to interact with the `JsonSchema` class, wha= t purpose > does it serve? Wouldn=E2=80=99t it be simpler to just extend `json_decode= ()` with > an optional `?string $schema =3D null` parameter? > There are couple of reasons for this: - It allows re-using the same parsed schema without a need to parse it multiple times for each decoding / validation - the class internally holds parsed representation of the schema. - We might want to introduce additional flags that will impact the parsing (e.g. default version) - It might allow a way to better cache schema between requests so it could further improve performance in the future - It will allow the possibility to get schema from other sources than string - e.g. from PHP array or even automatic creation from the class (that's why the JsonSchema is created using static method and not using constructor). This might be especially useful for object mapping. Kind regards, Jakub --000000000000198810063921c7eb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Fri, Jul 4, 2025 at 11:49= =E2=80=AFPM Valentin Udaltsov <udaltsov.valentin@gmail.com> wrote:
On Sta, 5 July 2025= =E2=80=AFat 00:04, Jakub Zelenka <bukka@php.net> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
Hello,
I would like introduce and open discussion for RFC proposi= ng the addition of JSON Schema validation support to JSON extension:
<= div>
https://wiki.php.net/rfc/json_schema_validation

If this is successful, it should be just the first = for further improvements (see the future scope).

K= ind regards,

Jakub

Hi, Jakub!

I like the idea. I have a cou= ple of initial thoughts:

1. Wouldn't it make sense to place all = the new classes under the `Json` namespace, similar to how it=E2=80=99s don= e in `ext-random`?

This would b= e widely inconsistent with the current interface / exception class in the e= xtension. The ext-random was a new extension so it's a completely diffe= rent case. I think it makes much more sense to keep the extension consisten= t than introducing new interface.
=C2=A0
2. If there=E2=80=99= s no way to interact with the `JsonSchema` class, what purpose does it serv= e? Wouldn=E2=80=99t it be simpler to just extend `json_decode()` with an op= tional `?string $schema =3D null` parameter?
<= br>
There are couple of reasons for this:

- It allows re-using the same parsed schema without a need to parse it mu= ltiple times for each decoding / validation - the class internally holds pa= rsed representation of the schema.
- We might want to introduce a= dditional flags that will impact the parsing (e.g. default version)
- It might allow a way to better cache schema between requests so it cou= ld further improve performance in the future
- It will allow the = possibility to get schema from other sources than string - e.g. from PHP ar= ray or even automatic creation from the class (that's why the JsonSchem= a=C2=A0is created using static method and not using constructor). This migh= t be especially useful for object mapping.

Kind re= gards,

Jakub

--000000000000198810063921c7eb--