public function fromJson($obj){ $this->bookId = $obj->bookId; $this->bookName =$obj->bookName; $this->userId = $obj->userId; foreach ($obj->sheets as $index => $sheet){ $newsheet = new Sheet(); $newsheet->fromJson($sheet); $newsheet->bookId=$this->bookId; $this->addSheet($newsheet); } if (is_array($obj->fontStyles)) { foreach ($obj->fontStyles as $fontStyle){ $newFontStyle = new FontStyle(); $newFontStyle->fromJson($fontStyle); $newFontStyle->bookId=$this->bookId; $this->addFontStyle($newFontStyle); } } }