Re: RFC Idea - json_validate() validate schema
| From: | juan carlos morales | Date: | Wed, 01 Mar 2023 15:48:40 +0000 |
| Subject: | Re: RFC Idea - json_validate() validate schema | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119639@lists.php.net to get a copy of this message | ||
Excellent Jakub, amazing, happy to know all this.
Lets wait for your proposal. Good luck, make it happen!
El mié, 1 mar 2023 a las 10:45, Jakub Zelenka (<bukka@php.net>) escribió:
>
> Hi,
>
> On Wed, Mar 1, 2023 at 1:36 PM Michał Marcin Brzuchalski <michal.brzuchalski@gmail.com>
> wrote:
>>
>> Hi Jakub
>>
>> śr., 1 mar 2023, 14:09 użytkownik Jakub Zelenka <bukka@php.net> napisał:
>>>
>>> >
>>> > Question ... are you planning to incorporate this by enhancing
>>> > json_validate() ???
>>> >
>>>
>>> Yes the plan is to initially enhance json_decode and json_validate that
>>> would get a new $schema argument . I plan to create a class for the
>>> actually schema as it needs to be parsed to its own representation so it is
>>> convenient to have it in the object. It could be also later created from
>>> the different sources than just JSON string (e.g. assoc array / stdClass or
>>> automatic generation from the class that I mentioned before) so it will be
>>> better to have it in the class.
>>>
>>> Regards
>>>
>>> Jakub
>>
>>
>> Do we really need this in core? What makes it less usable as an extension?
>>
>
> The primary motivation is that this allow stopping decoding / validation once first invalid
> part is found - basically this is going to be validated as parsed. It means this will eliminate all
> currently possible DOS attacks on the actual JSON parsing. There are other reasons that we can
> discuss in more details once proposed like better availability for users but those are just
> secondary reasons and sort of side effects.
>
> Regards
>
> Jakub