title: How to handle correctly JSON request in symfony?
body: <p>I'm trying to handle this problem:
  My app send JSON POST request with several information encoded in a Json. Example:</p>
  
  <pre><code>{"UserInfoA":{"1":123,"2":"hello","3":"bye","4":{"subinfo":1,"subinfo2":10}},
   "UserInfoB":{"a":"12345678","b":"asd"}} // and so on...
  </code></pre>
  
  <p>each UserInfo have:</p>
  
  <ul>
  <li>Its own entity (although some request may have information of more than one entity).</li>
  <li>A controller to persist this Object on DB and then give back the ID on this DB.</li>
  </ul>
  
  <p>So, to achieve this problem I did another controller like JsonHandler, which receive this request and then forward to each controller after gut this JSON into differents objects. Example:</p>
  
  <pre><code>public function getJson (Request $request){
      if (0 === strpos($request-&gt;headers-&gt;get('Content-Type'), 'application/json')) {
                  $data = json_decode($request-&gt;getContent(), true);
              }
      if (!isset($data['UserInfoA'])){
           return new JsonResponse('ERROR');
                }
      $uia = $data['UserInfoA'];
      $idInfoA = $this-&gt;forward('Path::dataAPersist',array('data'=&gt;$uia));
          }
      // same with userinfoB and other objects
      return $idInfoA ;
  </code></pre>
  
  <p>This works perfectly but Is it correct? Should i use services instead?</p>
  
  <p>EDIT : I need to response the ID in a Json and this->forward returns a Response, so i can't use JsonResponse and if a send directly $idInfoA just send the IDNUMBER not in a JSON, how can i do it?</p>
  
  <p><strong>To sum up</strong> : a Json listener that receive the information, work it and then dispatch to the corresponding controller. This listener, should be a controller, a service or another thing?</p>