Skip to content

Commit 5093694

Browse files
authored
Merge pull request #2655 from MashinaMashina/patch-1
Fix JSON error on recursion in data
2 parents 837020c + 99a65a8 commit 5093694

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

system/Format/JSONFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ class JSONFormatter implements FormatterInterface
5656
*/
5757
public function format($data)
5858
{
59-
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
59+
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;
6060

6161
$options = ENVIRONMENT === 'production' ? $options : $options | JSON_PRETTY_PRINT;
6262

6363
$result = json_encode($data, $options, 512);
6464

65-
if (json_last_error() !== JSON_ERROR_NONE)
65+
if ( ! in_array(json_last_error(), [JSON_ERROR_NONE, JSON_ERROR_RECURSION]))
6666
{
6767
throw FormatException::forInvalidJSON(json_last_error_msg());
6868
}

0 commit comments

Comments
 (0)