{"action":"opened","issue":{"url":"https://api.github.com/repos/schmittjoh/serializer/issues/387","labels_url":"https://api.github.com/repos/schmittjoh/serializer/issues/387/labels{/name}","comments_url":"https://api.github.com/repos/schmittjoh/serializer/issues/387/comments","events_url":"https://api.github.com/repos/schmittjoh/serializer/issues/387/events","html_url":"https://github.com/schmittjoh/serializer/issues/387","id":56457232,"number":387,"title":"ManyToOne and OneToMany Serialization Groups","user":{"login":"bassrock","id":1010384,"avatar_url":"https://avatars.githubusercontent.com/u/1010384?v=3","gravatar_id":"","url":"https://api.github.com/users/bassrock","html_url":"https://github.com/bassrock","followers_url":"https://api.github.com/users/bassrock/followers","following_url":"https://api.github.com/users/bassrock/following{/other_user}","gists_url":"https://api.github.com/users/bassrock/gists{/gist_id}","starred_url":"https://api.github.com/users/bassrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassrock/subscriptions","organizations_url":"https://api.github.com/users/bassrock/orgs","repos_url":"https://api.github.com/users/bassrock/repos","events_url":"https://api.github.com/users/bassrock/events{/privacy}","received_events_url":"https://api.github.com/users/bassrock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-03T23:45:48Z","updated_at":"2015-02-03T23:45:48Z","closed_at":null,"body":"I currently have a class called User that has a Transaction like so:\r\n\r\n```php\r\n/**\r\n * User\r\n *\r\n * @ORM\\Table()\r\n * @ORM\\Entity(repositoryClass=\"Acme\\BaseBundle\\Entity\\TransactionUserRepository\")\r\n * @ORM\\HasLifecycleCallbacks()\r\n */\r\nclass TransactionUser {\r\n\r\n    /**\r\n     * @var integer\r\n     *\r\n     * @ORM\\Column(name=\"id\", type=\"integer\")\r\n     * @ORM\\Id\r\n     * @ORM\\GeneratedValue(strategy=\"AUTO\")\r\n     * @Serializer\\Groups({\"transactionUser\"})\r\n     */\r\n    private $id;\r\n\r\n    /**\r\n     * @var string\r\n     *\r\n     * @ORM\\Column(name=\"name\", type=\"string\", length=255)\r\n     * @Serializer\\Groups({\"transactionUser\"})\r\n     */\r\n    private $name;\r\n\r\n    /**\r\n     * @var \\ Acme\\BaseBundle\\Entity\\Transaction $transaction\r\n     * @ORM\\ManyToOne(targetEntity=\"Acme\\BaseBundle\\Entity\\Transaction\", inversedBy=\"transactionUsers\", cascade={\"persist\", \"remove\"})\r\n     * @Serializer\\Groups({\"transactionUser\"})\r\n     */\r\n    private $transaction;\r\n\r\n}\r\n```\r\n\r\nAnd a transaction class:\r\n\r\n```php\r\n/**\r\n * Transaction\r\n *\r\n * @ORM\\Table()\r\n * @ORM\\Entity(repositoryClass=\"Acme\\BaseBundle\\Entity\\TransactionRepository\")\r\n * @ORM\\HasLifecycleCallbacks()\r\n */\r\nclass Transaction\r\n{\r\n    /**\r\n     * @var integer\r\n     *\r\n     * @ORM\\Column(name=\"id\", type=\"integer\")\r\n     * @ORM\\Id\r\n     * @ORM\\GeneratedValue(strategy=\"AUTO\")\r\n     * @Serializer\\Groups({\"transaction\"})\r\n     */\r\n    private $id;\r\n\r\n    /**\r\n     * @ORM\\OneToMany(targetEntity=\"Acme\\BaseBundle\\Entity\\TransactionUser\", mappedBy=\"transaction\", cascade={\"persist\", \"remove\"})\r\n     * @Serializer\\Groups({\"transaction\"})\r\n     */\r\n    private $transactionUsers;\r\n\r\n}\r\n```\r\n\r\nI return the TransactionUser in my rest controller like so with the serialization group of transaction and transactionUser:\r\n\r\n```php\r\n/** @var array|null $transactionUsers */\r\n$transactionUsers = $transactionUserRepository->findAllWithUserQueryBuilder($this->user)->getQuery()->getResult();\r\n\r\nreturn $transactionUsers;\r\n```\r\n\r\nI would like to return the transactionUser with the transaction inside it and the list of transaction users, but on the internal list of transaction users only want to output their id not the name property. Is there a way to handle this type of serialization?\r\n\r\n\r\nAlso it currently outputs it like so:\r\n\r\n```json\r\n[\r\n  {\r\n    \"id\": 3,\r\n    \"transaction_users\": {\r\n      \"1\": {\r\n        \"id\": 2,\r\n        \"name\": \"Test123\"\r\n      },\r\n      \"2\": {\r\n        \"id\": 3,\r\n        \"name\": \"Test\"\r\n      }\r\n    },\r\n    \"name\": \"Test\"\r\n  },\r\n  {\r\n    \"id\": 5,\r\n    \"transaction_users\": {\r\n      \"1\": {\r\n        \"id\": 4,\r\n        \"name\": \"Test1234\"\r\n      },\r\n      \"2\": {\r\n        \"id\": 5,\r\n        \"name\": \"Test1\"\r\n      }\r\n    },\r\n    \"name\": \"Test1\"\r\n  }\r\n]\r\n```\r\n\r\nBut I would like this:\r\n\r\n```json\r\n[\r\n  {\r\n    \"id\": 3,\r\n    \"transaction_users\": {\r\n      \"1\": {\r\n        \"id\": 2\r\n      },\r\n      \"2\": {\r\n        \"id\": 3\r\n      }\r\n    },\r\n    \"name\": \"Test\"\r\n  },\r\n  {\r\n    \"id\": 5,\r\n    \"transaction_users\": {\r\n      \"1\": {\r\n        \"id\": 4\r\n      },\r\n      \"2\": {\r\n        \"id\": 5\r\n      }\r\n    },\r\n    \"name\": \"Test1\"\r\n  }\r\n]\r\n```\r\n\r\n\r\n"}}