Description
PHP 8.3 comes with a new function json_validate which only tests if a string is valid JSON without actually parsing it into objects.
I believe it would be nice to have Nette\Utils\Json::validate as well, even if it was just a simple wrapper around json_validate, mostly for aesthetic purposes.
Currently, you must do a try-catch around Json::decode in order to validate a JSON. This sort-of breaks the visual flow of the code, plus is somewhat more expensive than Json::validate would be, if your only need is the validation, and you don't really need the fully parsed result.
Possibly, Json::validate could act more like a pure function and return a list of encountered problems instead of modifying the global state, which is what json_validate does.
Activity