Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tokushima committed Sep 2, 2023
1 parent bf30e91 commit 7187db5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/ebi/Json.php
Expand Up @@ -3,11 +3,12 @@

class Json{
private array $arr = [];

public function __construct(?string $json){
$this->arr = self::decode($json);
$arr = self::decode($json);
$this->arr = is_array($arr) ? $arr : [$arr];
}

/**
* パスから値を取得する
* @return mixed
Expand Down
3 changes: 3 additions & 0 deletions tests/test/ebi/Json.php
Expand Up @@ -19,3 +19,6 @@
$obj->jkl(new \test\Json());
eq('{"def":"aaa","ghi":100,"jkl":{"def":"aaa","ghi":100,"jkl":null}}',\ebi\Json::encode($obj));


$json = new \ebi\Json(null);
eq([null], $json->find());

0 comments on commit 7187db5

Please sign in to comment.