Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursion detected in JsonSerializationVisitor.php on line 29 #322

Closed
HooverG opened this issue Sep 2, 2013 · 1 comment
Closed

recursion detected in JsonSerializationVisitor.php on line 29 #322

HooverG opened this issue Sep 2, 2013 · 1 comment

Comments

@HooverG
Copy link

HooverG commented Sep 2, 2013

Hello,

I'm currently trying to expose groups for an ajax call.
If I user @expose on each field it works like a charm but if I replace it with @groups it throws the error recursion detected in JsonSerializationVisitor.php on line 29 and the results in my ajax return has a 'null' value.

Warning: json_encode() [function.json-encode]: recursion detected in /Applications/MAMP/htdocs/xxx-ref/vendor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php on line 29
{"datas":[{"datas":null,"errors":[],"redirect":null},{},{},{},{},{},{},{},{},{},{},{}],"errors":[],"redirect":null}

This is my call to the serializer =>
$context = new SerializationContext(false, 1);
$context->setSerializeNull(true);
$context->setGroups(array('details'));
$response->setContent($this->get('serializer')->serialize(array( 'datas'=>$datas, 'errors'=>$errors, 'redirect'=>$redirect), 'json', $context));

And this is the entity used

hybrids = new \Doctrine\Common\Collections\ArrayCollection(); $this->changeRequest = new \Doctrine\Common\Collections\ArrayCollection(); $this->translations = new \Doctrine\Common\Collections\ArrayCollection(); $this->valid = false; } public function getLocalityAsText() { if ($this->postalCode != null) { return strtolower( $this->country->getIso3166Alpha2()."-".$this->postalCode ); } else { return strtolower( $this->country->getIso3166Alpha2()."-".$this->locality->getName() ); } } public function __toString() { return $this->getFormattedAddress(); } public function translate($locale = null) { return new AddressTranslatorProxy( $this, $locale, array('formattedAddress'), 'XXX\CoreBundle\Entity\Geo\Translation\AddressTranslation', $this->translations ); } public function isPrecise() { return ( $this->getGeolocationType() === 'ROOFTOP' || $this ->getGeolocationType() === 'RANGE_INTERPOLATED' ); } public function getTranslations() { return $this->translations; } public function addTranslation(AddressTranslation $t) { if (!$this->translations->contains($t)) { $this->translations[] = $t; $t->setObject($this); } } public function removeTranslation(AddressTranslation $t) { if ($this->translations->contains($t)) { $this->translations->remove($t); } } public function getHybrids() { return $this->hybrids; } public function setHybrids($hybrids) { $this->hybrids = $hybrids; return $this; } public function getFormattedAddress($locale=null) { return $this->formattedAddress; } public function getId() { return $this->id; } public function getGeolocation() { return $this->geolocation; } public function setGeolocation($geolocation) { $this->geolocation = $geolocation; return $this; } public function getStreet() { return $this->street; } public function setStreet($street) { $this->street = $street; return $this; } public function getNumber() { return $this->number; } public function setNumber($number) { $this->number = $number; return $this; } public function getPostbox() { return $this->postbox; } public function setPostbox($postbox) { $this->postbox = $postbox; return $this; } public function getLocality() { return $this->locality; } public function setLocality($locality) { $this->locality = $locality; return $this; } public function getSublocality() { return $this->sublocality; } public function setSublocality($sublocality) { $this->sublocality = $sublocality; return $this; } public function getCountry() { return $this->country; } public function setCountry($country) { $this->country = $country; return $this; } public function getAdministrativeAreaLevel1() { return $this->administrativeAreaLevel1; } public function setAdministrativeAreaLevel1($administrativeAreaLevel1) { $this->administrativeAreaLevel1 = $administrativeAreaLevel1; return $this; } public function getAdministrativeAreaLevel2() { return $this->administrativeAreaLevel2; } public function setAdministrativeAreaLevel2($administrativeAreaLevel2) { $this->administrativeAreaLevel2 = $administrativeAreaLevel2; return $this; } public function getAdministrativeAreaLevel3() { return $this->administrativeAreaLevel3; } public function setAdministrativeAreaLevel3($administrativeAreaLevel3) { $this->administrativeAreaLevel3 = $administrativeAreaLevel3; return $this; } public function getGeolocationType() { return $this->geolocationType; } public function setGeolocationType($geolocationType) { $this->geolocationType = $geolocationType; return $this; } public function getViewportSouthWest() { return $this->viewportSouthWest; } public function setViewportSouthWest($viewportSouthWest) { $this->viewportSouthWest = $viewportSouthWest; return $this; } public function getViewportNorthEast() { return $this->viewportNorthEast; } public function setViewportNorthEast($viewportNorthEast) { $this->viewportNorthEast = $viewportNorthEast; return $this; } public function getChangeRequest() { return $this->changeRequest; } public function setChangeRequest($changeRequest) { $this->changeRequest = $changeRequest; return $this; } public function setFormattedAddress($formattedAddress) { $this->formattedAddress = $formattedAddress; return $this; } public function getPostalCode() { return $this->postalCode; } public function setPostalCode($postalCode) { $this->postalCode = $postalCode; return $this; } public function getValid() { return $this->valid; } public function setValid($valid) { $this->valid = $valid; return $this; } public function getSlug() { return $this->slug; } public function setSlug($slug) { $this->slug = $slug; return $this; } } Any help appreciated I'm stuck for hours on this problem. Thank you.
@HooverG
Copy link
Author

HooverG commented Sep 2, 2013

You can close this issue !

@HooverG HooverG closed this as completed Sep 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant