Skip to content

Commit

Permalink
Merge pull request #50 from systopia/fix-JsonConverter-handling-of-em…
Browse files Browse the repository at this point in the history
…pty-array

JsonConverter: Fix handling of empty arrays
  • Loading branch information
dontub authored Mar 13, 2024
2 parents 6934400 + 585db1f commit 6e73d45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Form/Util/JsonConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static function toArray(\stdClass $data): array {
* @throws \JsonException
*/
public static function toStdClass(array $data): \stdClass {
if ([] === $data) {
return new \stdClass();
}

$result = \json_decode(\json_encode($data, JSON_THROW_ON_ERROR));
Assertion::isInstanceOf($result, \stdClass::class);

Expand Down

0 comments on commit 6e73d45

Please sign in to comment.