// *** before: ***
function isValidJson(string $json): bool {
// decoding the whole payload just to check its validity wastes memory
json_decode($json);
return json_last_error() === JSON_ERROR_NONE;
}
// *** in version 8.3: ***
function isValidJson(string $json): bool {
return json_validate($json);
}