Skip to content

Commit

Permalink
Fix JSON decoding issue in Json.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Jan 22, 2024
1 parent b1cf911 commit 2bb5081
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Utils/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ public function save(string $saveTo, bool $console = true): void

public function toArray(bool $is_associative = true): array
{
if (! $this->contents) {
ray($this->contents);
if (is_null($this->contents)) {
return [];
}

if (is_array($this->contents)) {
return $this->contents;
}

return json_decode($this->contents, $is_associative);
$data = json_decode($this->contents, $is_associative);
if (is_null($data)) {
return [];
}

return $data;
}

public function toObject(): object
Expand Down

0 comments on commit 2bb5081

Please sign in to comment.