Skip to content

Commit d842546

Browse files
committed
Fix Json renderer with empty changes
Signed-off-by: Jack Cherng <[email protected]>
1 parent cd38b50 commit d842546

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: src/Renderer/Html/Json.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,26 @@ final class Json extends AbstractHtml
2626
*/
2727
public function render(): string
2828
{
29+
$changes = $this->getChanges();
30+
31+
if (empty($changes)) {
32+
return self::getIdenticalResult();
33+
}
34+
2935
return \json_encode(
30-
$this->getChanges(),
36+
$changes,
3137
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES
3238
);
3339
}
3440

41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public static function getIdenticalResult(): string
45+
{
46+
return '[]';
47+
}
48+
3549
/**
3650
* {@inheritdoc}
3751
*/

0 commit comments

Comments
 (0)