Re: RFC json_validate() - status: Under Discussion

From: Date: Fri, 26 Aug 2022 09:14:42 +0000
Subject: Re: RFC json_validate() - status: Under Discussion
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-118490@lists.php.net to get a copy of this message
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.brzuchalski@gmail.com> wrote: > Hi Dusk, > > pt., 26 sie 2022 o 08:17 Dusk <dusk@woofle.net> napisał(a): > > > On Aug 25, 2022, at 21:47, Michał Marcin Brzuchalski < > > michal.brzuchalski@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, >

« previous php.internals (#118490) next »