quote
> you can't efficiently validate JSON in userland

Has anyone actually put that claim to the test? Has anyone actually made a
userland json validator (not just wrap json_decode()/json_last_error()) for
performance comparison?
( if not, https://www.json.org/JSON_checker/JSON_checker.c  would probably
be a good start)

On Fri, 26 Aug 2022 at 11:00, Michał Marcin Brzuchalski <
michal.brzuchal...@gmail.com> wrote:

> Hi Dusk,
>
> pt., 26 sie 2022 o 08:17 Dusk <d...@woofle.net> napisał(a):
>
> > On Aug 25, 2022, at 21:47, Michał Marcin Brzuchalski <
> > michal.brzuchal...@gmail.com> wrote:
> > > The same goes here and I'm not convinced we should introduce next small
> > function that can be simply implemented in user land.
> >
> > What "simple implementation in userland" do you have in mind? Can you
> > provide an example?
> >
> > json_decode() is not an acceptable substitute here -- as David Gebler has
> > observed, decoding a large JSON structure can have a significant impact
> on
> > memory usage, even if the data is immediately discarded. Any
> implementation
> > based on string processing, on the other hand, is likely to be
> dramatically
> > slower, and may have subtle differences in behavior from PHP's JSON
> parser.
>
>
> A `json_decode()` is a substitute that IMO solves 99% of use cases.
> If I'd follow your logic and accept every small addition that handles 1% of
> use cases, somebody will raise another RFC
> for simplexml_validate_string or yaml_validate and the next
> PhpToken::validate.
> All above can be valid if we trust that people normally validate 300MB
> payloads to do nothing if they DON'T fail and there is nothing strange
> about that.
>
> Cheers,
>

Reply via email to