<?php json_last_error(): int
<?php $lastLine = end($output); if (! empty($lastLine)) { $result = json_decode($lastLine, true, 512, JSON_THROW_ON_ERROR); if (json_last_error()) { throw new Exception(json_last_error_msg()); } } else {
<?php $error = trim($matches[1] ?? ''); if ($error !== '') { $result = json_decode($error, true, 512, JSON_THROW_ON_ERROR); if (json_last_error()) { throw new Exception(json_last_error_msg()); } }