title: Could not decode JSON, syntax error - malformed JSON
body: <p>I am sending an AJAX POST with JSON data to a Symfony2 controller. Without any data specified, the controller does create an empty record and returns success (no errors). However, when I pass data in POST it gives me the error shown in title. Here is my code for AJAX: </p>
  
  <pre><code>              $.ajax({
                  dataType: "json",
                  type: "POST",
                  data: {
                          "useruid": "Nothing",
                          "type": "Office in Space",
                          "latitude": "12",
                          "longitude": "100",
                          "displayed": "true",
                          "public": "true",
                          "verified": "true",
                          "street": "Something",
                          "city": "Something",
                          "country": "Space",
                          "region": "North Space",
                          "created": "2009-03-07T00:00:00-0500",
                          "delete_status": "active"
  },
                  url: "/web/app_dev.php/address/",
                  success: function (responseText)
                  {
                      console.log("Request was successful, data received: " + JSON.stringify(responseText)); 
  
                  },
                  error: function (error) {
                      alert(JSON.stringify(error));
                  }
              });
  </code></pre>
  
  <p>To deserialize the JSON, here is my controller code: </p>
  
  <pre><code>public function createAction(Request $request)
  {
  
  
      $content = $this-&gt;get('request')-&gt;getContent();
      var_dump($content); 
      $serializer = $this-&gt;get('jms_serializer'); 
      $entity = $serializer-&gt;deserialize($content, 'Name\NameBundle\Entity\Address', 'json');
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
      return array(
          'entity' =&gt; $entity,
          'form'   =&gt; $form-&gt;createView(),
      );
  
  }
  </code></pre>
  
  <p>I am using JMSSerializer bundle. What is the reason why it cannot decode the JSON? I validated my JSON with JSONlint and it was okay. Any ideas?</p>
  
  <p>** Edited code: Added Entity Class **</p>
  
  <pre><code>namespace Factory\WebServicesBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  use JMS\Serializer\Annotation\Type;
  
  /**
   * Address
   * @ORM\Table(name="address")
   * @ORM\Entity
   */
  class Address
  {
  /**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer", nullable=false)
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="IDENTITY")
   * @JMS\Serializer\Annotation\Type("integer")
   */
  private $id;
  
  /**
   * @var string
   *
   * @ORM\Column(name="useruid", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $useruid;
  
  /**
   * @var string
   *
   * @ORM\Column(name="type", type="string", nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $type;
  
  /**
   * @var string
   *
   * @ORM\Column(name="latitude", type="string", length=120, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $latitude;
  
  /**
   * @var string
   *
   * @ORM\Column(name="longitude", type="string", length=120, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $longitude;
  
  /**
   * @var boolean
   *
   * @ORM\Column(name="displayed", type="boolean", nullable=true)
   * @JMS\Serializer\Annotation\Type("boolean")
   */
  private $displayed;
  
  /**
   * @var boolean
   *
   * @ORM\Column(name="public", type="boolean", nullable=true)
   * @JMS\Serializer\Annotation\Type("boolean")
   */
  private $public;
  
  /**
   * @var boolean
   *
   * @ORM\Column(name="verified", type="boolean", nullable=true)
   * @JMS\Serializer\Annotation\Type("boolean")
   */
  private $verified;
  
  /**
   * @var string
   *
   * @ORM\Column(name="street", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $street;
  
  /**
   * @var string
   *
   * @ORM\Column(name="city", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $city;
  
  /**
   * @var string
   *
   * @ORM\Column(name="country", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $country;
  
  /**
   * @var string
   *
   * @ORM\Column(name="locality", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $locality;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="region", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $region;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="code", type="string", length=100, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   * 
   */
  private $code;
  
  /**
   * 
   * @var string
   *
   * 
   * @ORM\Column(name="pobox", type="string", length=100, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   * 
   */
  private $pobox;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="telephone", type="string", length=60, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $telephone;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="cellphone", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $cellphone;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="email", type="string", length=200, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $email;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="facsmile", type="string", length=60, nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $facsmile;
  
  /**
   * @var \DateTime
   *
   * 
   * @ORM\Column(name="created", type="datetime", nullable=true)
   * @JMS\Serializer\Annotation\Type("DateTime")
   */
  private $created;
  
  /**
   * @var \DateTime
   *
   * 
   * @ORM\Column(name="modified", type="datetime", nullable=true)
   * @JMS\Serializer\Annotation\Type("DateTime")
   */
  private $modified;
  
  /**
   * @var string
   *
   * 
   * @ORM\Column(name="delete_status", type="string", nullable=true)
   * @JMS\Serializer\Annotation\Type("string")
   */
  private $deleteStatus;
  </code></pre>