An Entity is given with these properties: 

```
class Translation
{
  /**
   * @var string
   * @SerializedName("language_code")
   */
  private $lang;

  /**
   * @var string
   * @SerializedName("text")
   */
  private $translation;

  /**
   * @var int
   */
  private $language_id;
}

```

The Controller looks like this:

```
class DefaultController extends {
    public function indexAction(Request $request) {
        $translation = $this->getDoctrine()->getRepository('AppBundle:Translation')->findAll();
        $serializer = SerializerBuilder::create()->build();
        $translationJson = $serializer->serialize($translation, 'json');

        return new Response($translationJson);
   }    
}

```

My front-end expects a json format like this:

```
 {
  "en" : "yes",
  "de" : "ja",
  "it" : "si"  
 }

```

My project is much more complex but this is a minified description of the problem. My only concern is how can I format the properties into a key-value pair in a json object.

Can I achieve that using Annotations?  

If not, then how?

**EDIT**

Translation Entity has a ManyToOne relation with Languages Entity: 

```
class Languages
{
  /**
   * @var int
   */
  private $id;

  /**
   * @var int
   * @ORM\OneToMany(targetEntity="Translation", mappedBy="translation_id", cascade={"persist"}, orphanRemoval=true)
   */
  private $translations;
}

```