public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context) { $rs = parent::endVisitingObject($metadata, $data, $type, $context); // Force JSON output to "{}" instead of "[]" if it contains either no properties or all properties are null. if (empty($rs)) { $rs = new \ArrayObject(); } return $rs; }
public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context) { $rs = parent::endVisitingObject($metadata, $data, $type, $context); // Force JSON output to "{}" instead of "[]" if it contains either no properties or all properties are null. if (empty($rs)) { $rs = new \ArrayObject(); if (array() === $this->getRoot() && 0 === $context->getDepth()) { $this->setRoot(clone $rs); } } return $rs; }