Skip to content

Commit d96a2d7

Browse files
authored
Merge pull request #16 from xp-forge/refactor/empty-objects
Return `{}` as empty object instead of empty array
2 parents 248dc58 + 22c0e13 commit d96a2d7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/php/text/json/Input.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function escaped($pos, $len, &$offset) {
9292
protected function readObject($nesting) {
9393
$token= $this->nextToken();
9494
if ('}' === $token) {
95-
return [];
95+
return (object)[];
9696
} else if (null !== $token) {
9797
$result= [];
9898
if (++$nesting > $this->maximumNesting) {

src/test/php/text/json/unittest/JsonInputTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function read_keyword($expected, $source) {
118118

119119
#[Test, Values(['{}', '{ }'])]
120120
public function read_empty_object($source) {
121-
Assert::equals([], $this->read($source));
121+
Assert::equals((object)[], $this->read($source));
122122
}
123123

124124
#[Test, Values(['{"key": "value"}', '{"key" : "value"}', '{ "key" : "value" }'])]

0 commit comments

Comments
 (0)