Jmsserializerbundle: AccessorOrder : properties vs virtualProperty

Created on 30 Mar 2016  路  3Comments  路  Source: schmittjoh/JMSSerializerBundle

Hello,

The actual behavior of the serializer is to put virtual property on top of the resulting serialized string, but ...
Shouldn't be a way to set the accessor order like : "properties first, virtual property after ?"
I know it's possible to set this order with the @AccessorOrder property, but I think it could be easier.
Maybe I'm missing a feature of this bundle?

Regards,

Most helpful comment

Vendor\MyBundle\Model\ClassName:
    accessor_order: custom
    custom_accessor_order: [propertyName1, propertyName2, ..., propertyNameN]

see https://jmsyst.com/libs/serializer/master/reference/yml_reference

All 3 comments

if the order of properties is what you need, then @AccessorOrder does exactly what you need

i no this is clossed...but @goetas how would i be able to use accessOrder in yaml

---
Appbundle\Class\Foo:
  exclusion_policy: ALL
  properties:
    id:
      expose: true
      type: string
    name:
      expose: true
      type: string

i want name to come before ID...i could only see examples online to do this inline within the model class...any ideas

Vendor\MyBundle\Model\ClassName:
    accessor_order: custom
    custom_accessor_order: [propertyName1, propertyName2, ..., propertyNameN]

see https://jmsyst.com/libs/serializer/master/reference/yml_reference

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jejec picture Jejec  路  8Comments

egonolieux picture egonolieux  路  4Comments

renan-taranto picture renan-taranto  路  5Comments

simshaun picture simshaun  路  9Comments

CsabaNa picture CsabaNa  路  3Comments