/** * Converts the response in JSON format to the list of value objects i.e Geo * * @param json * - response in JSON format * * @return List of Geo Points object filled with json data * */ public function buildArrayResponse($json) { $geoObjList = array(); $jsonObj = new JSONObject($json); $jsonObjApp42 = $jsonObj->__get("app42"); $jsonObjResponse = $jsonObjApp42->__get("response"); $jsonObjGeoStorage = $jsonObjResponse->__get("geo"); if ($jsonObjGeoStorage->__get("storage") instanceof JSONObject) { //Single Item $jsonObjGeoStorage = $jsonObjGeoStorage->__get("storage"); $geoObj = new Geo(); $pointList = array(); $geoObj->setPointList($pointList); $geoObj->setStrResponse($json); $geoObj->setResponseSuccess($jsonObjResponse->__get("success")); $this->buildObjectFromJSONTree($geoObj, $jsonObjGeoStorage); array_push($geoObjList, $geoObj); if ($jsonObjGeoStorage->has("points")) { $this->buildInternalObj($geoObj, $jsonObjGeoStorage); } } else { //Multiple Item $jsonStorageArray = $jsonObjGeoStorage->getJSONArray("storage"); for ($i = 0; $i < count($jsonStorageArray); $i++) { $jsonObjStorage = $jsonStorageArray[$i]; $geoObj = new Geo(); $pointList = array(); $geoObj->setPointList($pointList); $geoObj->setStrResponse($json); $geoObj->setResponseSuccess($jsonObjResponse->__get("success")); $jsonObjStorage = new JSONObject($jsonObjStorage); $this->buildObjectFromJSONTree($geoObj, $jsonObjStorage); array_push($geoObjList, $geoObj); if ($jsonObjStorage->has("points")) { $this->buildInternalObj($geoObj, $jsonObjStorage); } } } return $geoObjList; }