多个jsonSerialize实体

I've been doing some research without any result. So I come here to ask directly the question.

I have an entity, in order to return it into some api call, I need to serialize it.

For now I have something like that

class Place implements \JsonSerializable{
    [...] fields lists [...]

    public function jsonSerialize(){
        return array(
            "id" => $this->id,
            "title"  => $this->title);
   }
}

This is working right, but, i would like to be able to have multiple definition for the serialization because for the api1 I might want to return id and title, but may be for the api2 I would like to return id / title and resume.

Is there a way to make a condition into the jsonSerialize() ? Or some other way ? I'm pretty sure I already have done something like that in Java, that might be possible in php.

Thanks for your help.

Since Symfony 2.7, you can use the serializer and serializer groups to provide different data. You can set it up via annotation.

Otherwise, you can use JMSSerializerBundle, it contains alose groups and other useful features. JMSSerializerBundle