Re: RFC json_validate() - status: Under Discussion

From: Date: Fri, 26 Aug 2022 06:52:50 +0000
Subject: Re: RFC json_validate() - status: Under Discussion
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-118486@lists.php.net to get a copy of this message
El vie, 26 ago 2022 a las 6:47, Michał Marcin Brzuchalski (<michal.brzuchalski@gmail.com>) escribió: > > > I share the same opinion you expressed here even though you admit in recent email that you > changed your mind. > > In recent versions we tend to accept more and more small standard library functions with IMO > questionable argumentation. The same goes here and I'm not convinced we should introduce next > small function that can be simply implemented in user land. Sorry but I dont think that a JSON parser with memory usage zero (or maybe a few bytes) can be simply done in the userland. This function (json_validate) is small by itself, but gives you access to the JSON parser. Can you please provide an example of what you commented? > Any example testing > 3MB JSON string are for me edge cases that normally don't happen > often to deserve special treatment. I don't agree with your definition of "edge case" here, as edge cases depend/belong on/to the system under analysis. By the way, the test case provided in the PR , "test 005" uses a json-string of about 3 MB (maybe 3.1) , and in order to decode it json_decode() needs something around 109 MB of memory. For me, validation can be done in a better and efficient way, like it has been probe with this proposal. > If we keep the tendency to pollute already bloated standard library with an army of small > functions that could have not exists and be replaced with normal PHP counterparts IMHO we'll > end with frustration from developers as I believe DX slowly falls down here. Last but not least, I want to say that the function json_validate() is small, easy to maintain and extend if needed, and at the same gives us access to something that is not trivial to write in userland .... the existing JSON parser. RFC: https://wiki.php.net/rfc/json_validate Implementation: https://github.com/php/php-src/pull/9399

« previous php.internals (#118486) next »