function buildArrayResponse($json) { $giftsJSONObj = $this->getServiceJSONObject("gifts", $json); $giftList = array(); if ($giftsJSONObj->__get("gift") instanceof JSONObject) { $giftJSONObj = $giftsJSONObj->__get("gift"); $giftObj = new Gift(); $this->buildObjectFromJSONTree($giftObj, $giftJSONObj); $giftObj->setStrResponse($json); $giftObj->setResponseSuccess($this->isRespponseSuccess($json)); array_push($giftList, $giftObj); } else { $giftJSONArray = $giftsJSONObj->getJSONArray("gift"); for ($i = 0; $i < count($giftJSONArray); $i++) { $giftJSONObj = $giftJSONArray[$i]; $gift = new Gift(); $gift->setStrResponse($json); $gift->setResponseSuccess($this->isRespponseSuccess($json)); $giftJSONObject = new JSONObject($giftJSONObj); $this->buildObjectFromJSONTree($gift, $giftJSONObject); array_push($giftList, $gift); } } return $giftList; }