{"id":1642,"date":"2022-08-30T15:18:14","date_gmt":"2022-08-30T15:18:14","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/problem-about-jmsserializerbundle-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:14","modified_gmt":"2022-08-30T15:18:14","slug":"problem-about-jmsserializerbundle-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-jmsserializerbundle-collection-of-common-programming-errors\/","title":{"rendered":"problem about jmsserializerbundle-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fa38c3a267295fb2978ded32786073d2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntolgap<br \/>\nsymfony2 doctrine doctrine2 symfony-2.1 jmsserializerbundle<br \/>\nI&#8217;m having this issue with JMSSerializerBundle. It basically gives me an exception for something that I&#8217;ve already done. This is my entity:Edited to avoid confusion about annotation lines&lt;?phpnamespace My\\ProjectBundle\\Entity; use JMS\\SerializerBundle\\Annotation\\Type;use Doctrine\\ORM\\Mapping as ORM;\/*** My\\ProjectBundle\\Entity\\Music* * @ORM\\Table()* @ORM\\Entity(repositoryClass=&#8221;My\\ProjectBundle\\Entity\\MusicRepository&#8221;)*\/ class Music extends Post { \/*** @var integer $id* * @ORM\\Column(name=&#8221;id<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/GPPPT.gif?s=32&amp;g=1\" \/><br \/>\nartworkad ?<br \/>\nsymfony2 fosuserbundle jmsserializerbundle symfony-2.3<br \/>\nBasically I want to deserialize json to user object. Like this$serializer = $this-&gt;get(&#8216;jms_serializer&#8217;);$data = $serializer-&gt;deserialize($this-&gt;get(&#8216;request&#8217;)-&gt;getContent(),&#8217;My\\FooBundle\\Entity\\User&#8217;, &#8216;json&#8217;);The request data passed to deserializer:{&#8220;id&#8221;:2,&#8221;username&#8221;:&#8221;&#8230;@gmail.com&#8221;,&#8221;username_canonical&#8221;:&#8221;&#8230;@gmail.com&#8221;, &#8230; }Thrown error:request.CRITICAL: Uncaught PHP ExceptionJMS\\Serializer\\Exception\\RuntimeException: &#8220;You must define a type forFOS\\UserBundle\\Model\\User::$username.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/36cf5241fceb77ba7cf57ab4aa63ccd8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTony<br \/>\nsymfony2 doctrine2 doctrine fosrestbundle jmsserializerbundle<br \/>\nI just upgraded our Symfony installation from 2.2 -&gt; 2.3.1 (along with other dependent packages). Now it the JMS serializer no longer serializes existing doctrine objects. I outline relevant changes I&#8217;ve made below:Some of the composer.json&#8221;symfony\/symfony&#8221;: &#8220;2.3.*&#8221;,&#8221;symfony\/framework-bundle&#8221;: &#8220;2.3.*&#8221;,&#8221;doctrine\/common&#8221;: &#8220;2.*&#8221;,&#8221;doctrine\/dbal&#8221;: &#8220;2.*&#8221;,&#8221;doctrine\/orm&#8221;: &#8220;2.*&#8221;,&#8221;friendsofsymfony\/jsrouting-bundle&#8221;: &#8220;dev-master&#8221;,&#8221;friendsofsymfony\/rest-bundle&#8221;: &#8220;0.12.*&#8221;,&#8221;friendsofsymfony\/rest&#8221;: &#8220;0.*&#8221;,&#8221;jms\/<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:13:30. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>tolgap symfony2 doctrine doctrine2 symfony-2.1 jmsserializerbundle I&#8217;m having this issue with JMSSerializerBundle. It basically gives me an exception for something that I&#8217;ve already done. This is my entity:Edited to avoid confusion about annotation lines&lt;?phpnamespace My\\ProjectBundle\\Entity; use JMS\\SerializerBundle\\Annotation\\Type;use Doctrine\\ORM\\Mapping as ORM;\/*** My\\ProjectBundle\\Entity\\Music* * @ORM\\Table()* @ORM\\Entity(repositoryClass=&#8221;My\\ProjectBundle\\Entity\\MusicRepository&#8221;)*\/ class Music extends Post { \/*** @var integer $id* * @ORM\\Column(name=&#8221;id [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1642","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1642"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1642\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}