JSON root name in Serialized Entity

I use FOSRestBundle and JMSSerializerBundle to output the JSON data that will be consumed by the ember application. I would like to use the built-in ember-data adapters and the JSON format, which is expected to have a root name. My current JSON looks like this:

{
     "user_id": 1
     "first": "Dan"
     "email": "dan@email.com" 
 }

Ember is expected and I want:

{
 "user":
   {
     "user_id": 1
     "first": "Dan"
     "email": "dan@email.com" 
    }
}

User is the name of the object. I am pretty sure that this is just a configuration, but looking through the documentation, I cannot find what to install. I tried @XmlRoot, but this does not seem to affect the JSON result (expected).

+4
source share
2 answers

, API-, API, .

ember:

JSON RESTAdapter EmberJS

0

, FOSRestController, , , , root node :

$fooThing = $em->getRepository('Foo')->find($id);
$view = $this->view(array('foo' => $fooThing), 200);
return $this->handleView($view);

, XML, API, .

0

Source: https://habr.com/ru/post/1545088/


All Articles