On Wed, Mar 1, 2023 at 6:05 PM Larry Garfield <la...@garfieldtech.com> 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.mora...@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
>
> --
> 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.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to