예제 #1
0
 /**
  * @see http://php.net/manual/en/jsonserializable.jsonserialize.php
  */
 public function jsonSerialize()
 {
     $json = parent::jsonSerialize();
     if (isset($this->coordinates)) {
         $json['coordinates'] = $this->coordinates;
     }
     return $json;
 }
예제 #2
0
 /**
  * @see http://php.net/manual/en/jsonserializable.jsonserialize.php
  */
 public function jsonSerialize()
 {
     $json = parent::jsonSerialize();
     $json['geometry'] = isset($this->geometry) ? $this->geometry->jsonSerialize() : null;
     $json['properties'] = isset($this->properties) ? $this->properties : null;
     // Ensure empty associative arrays are encoded as JSON objects
     if ($json['properties'] === array()) {
         $json['properties'] = new \stdClass();
     }
     if (isset($this->id)) {
         $json['id'] = $this->id;
     }
     return $json;
 }
 /**
  * @see http://php.net/manual/en/jsonserializable.jsonserialize.php
  */
 public function jsonSerialize()
 {
     return array_merge(parent::jsonSerialize(), array('features' => array_map(function (Feature $feature) {
         return $feature->jsonSerialize();
     }, $this->features)));
 }