You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From PHP 8.3, a new json_validate can be used to determine if a string is valid json or not. This can allow us replace the current implementation of Aedart\Utils\Json::isValid().
Flags
The new json_validate also accepts depth and flags arguments. This means that the Json::isValid() method also must accept those arguments and the method signature must therefore be expanded, e.g.
json_validate() uses less memory than json_decode, which means that one could improve performance handling decoding errors, in the Json::decode() method. See article for details.
Also, perhaps we should also consider method for obtaining the last error...
The text was updated successfully, but these errors were encountered:
aedart
changed the title
[PHP8.3] Replace Json::isValid() implementation with new json_validate()
[PHP 8.3] Replace Json::isValid() implementation with new json_validate()
Nov 4, 2022
For now, the current implementation of isValid() should be good enough. Once PHP 8.3 is set as the minimum required version, then the native function should be used.
Description
From PHP 8.3, a new
json_validate
can be used to determine if a string is valid json or not. This can allow us replace the current implementation ofAedart\Utils\Json::isValid()
.Flags
The new
json_validate
also accepts depth and flags arguments. This means that theJson::isValid()
method also must accept those arguments and the method signature must therefore be expanded, e.g.Additional
json_validate()
uses less memory thanjson_decode
, which means that one could improve performance handling decoding errors, in theJson::decode()
method. See article for details.Also, perhaps we should also consider method for obtaining the last error...
The text was updated successfully, but these errors were encountered: