On Wed, Mar 1, 2023 at 5: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().)
>

 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

Reply via email to