Re: RFC json_validate() - status: Under Discussion

From: Date: Fri, 26 Aug 2022 10:23:47 +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-118503@lists.php.net to get a copy of this message
Hi On 8/26/22 11:00, Michał Marcin Brzuchalski wrote:
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.
You phrase this as if this was a bad thing. But yes, if PHP would include a YAML parser in core (there appears to be one in PECL) then having a yaml_validate() function with a value-add compared to actually constructing the object representation then it would certainly be an appropriate inclusion. I don't see why JSON should be special here. For XML my understanding is that the XMLReader class can already be used to efficiently validate an XML input in userland [1], because that class is defined to be a streaming parser. These types of parsers are not uncommon in XML land. Best regards Tim Düsterhus [1] https://www.php.net/manual/en/xmlreader.isvalid.php

« previous php.internals (#118503) next »