Manuel Corbet
Manuel Corbet

Reputation: 45

JMS Serializer many to one relation, field on same level of main entity

I have an entity with a manyToOne relation, I want to serialize this entity with JMS serializer on Symfony. But I want the related entity on the same level of the main entity, like if fields are just complementary fields of my main entity.

I have this :

"parcel_movement_action_button": {
  "code": "string",
  "type": "string"
},
"button_class": "string",
"value": "string"

I want this :

  "code": "string",
  "type": "string",
  "button_class": "string",
  "value": "string"

Is it possible ?

Upvotes: 0

Views: 583

Answers (1)

Abdelhak ouaddi
Abdelhak ouaddi

Reputation: 472

Yes it's possible, you must use virtual property to do that https://jmsyst.com/libs/serializer/master/reference/annotations#virtualproperty

Upvotes: 2

Related Questions