diff --git a/lib/protobuf.php b/lib/protobuf.php index 0c67683..4d94eb1 100644 --- a/lib/protobuf.php +++ b/lib/protobuf.php @@ -820,12 +820,13 @@ public static function FromString(string $str): mixed { if ($str === "null") { return null; } - $data = \json_decode($str, true, 512, \JSON_FB_HACK_ARRAYS); + $error_data = null; + $data = \json_decode_with_error($str, inout $error_data, true, 512, \JSON_FB_HACK_ARRAYS); if ($data !== null) { return $data; } throw new \ProtobufException( - "json_decode failed; ".\json_last_error_msg(), + "json_decode failed; ".($error_data[1] ?? ''), ); }