public function jsonSerialize()
 {
     $parent = parent::jsonSerialize();
     foreach (DTOMapper::collectionFields($this->name()) as $field) {
         if (!empty($parent[$field])) {
             $parent[$field] = DTOMapper::unmapCollection($parent[$field], $this->name(), $field);
         }
     }
     return $parent;
 }
 /** This function combines non-composite resources with the proper representation of composite resources
  * into a data array which can be encoded by json_encode() creating a valid request for the Report Server
  *
  * @return array
  */
 public function jsonSerialize()
 {
     $allFields = parent::jsonSerialize();
     $compositeFields = CompositeDTOMapper::compositeFields(get_class($this));
     foreach ($compositeFields as $key) {
         if (isset($this->{$key})) {
             $allFields[$key] = $this->resolveSubresource($key, $this->{$key}, $this->name());
         }
     }
     return $allFields;
 }