/**
* @return array
*/
public function jsonSerialize()
{
$output = array();
foreach (get_object_vars($this) as $key => $value) {
if ($value instanceof \DateTime) {
// Clumsy way to avoid writing mappings for sub-documents and all that.
$output[$key] = Type::getType('datetime')->convertToCouchDBValue($value);
} else {
$output[$key] = $value;
}
}
return array_filter($output);
}