Skip to content

Serialize annotations

BowlOfSoup edited this page Sep 16, 2020 · 1 revision

Group (context) support

Use property 'group' to separate context. See how you can use this in the 'wrapper element' section below.

/**
 * @Bos\Serialize(group={"group-name"})
 */
class ClassToBeSerialized
{

Wrapper element

When outputting to a specific encoding you can indicate the wrapping element, this element will be the root node. You can and should indicate a group (context), use property 'group' to separate context.

/**
 * @Bos\Serialize(wrapElement="SomeWrapperElement", group={"some_group"})
 * @Bos\Serialize(wrapElement="data", group={"other_group"})
 */
class ClassToBeSerialized
{

Sort properties

You can have the serializer sort all data by key. The normalized data (array) will be sorted, so the serialized output is also sorted.

/**
 * @Bos\Serialize(sortProperties=true)
 */
class ClassToBeSerialized
{