Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property of the type array is not in alphabetic order after serialization #196

Closed
slopjong opened this issue Dec 4, 2013 · 2 comments
Closed

Comments

@slopjong
Copy link

slopjong commented Dec 4, 2013

When serializing an object of the following annotated class, the resulting JSON has not all the properties in an alphabetic order.

/**
 * @JMS\AccessorOrder("alphabetical")
 * @JMS\XmlRoot("Test")
 */
class Test
{
    /**
     * @JMS\SerializedName("Name")
     * @JMS\Type("string")
     */
    protected $Name = "";

    /**
     * @JMS\SerializedName("Id")
     * @JMS\Type("integer")
     */
    protected $Id = "";

    /**
     * @JMS\SerializedName("Ip")
     * @JMS\Type("string")
     */
    protected $Ip = '';

    /**
     * @JMS\SerializedName("InterfaceList")
     * @JMS\XmlList(inline = false, entry = "Interface")
     * @JMS\Type("array<string>")
     */
    protected $interfaces = array();

    ...
}

Result:

{
    "Id": "",
    "Ip": "",
    "Name": "",
    "InterfaceList": [
        ...
    ]
}

I tested only with an array but for an ArrayCollection the behaviour might be the same.

@RobertSmolarczyk
Copy link

May the @AccessOrder Attribute could help you?

@goetas
Copy link
Collaborator

goetas commented Apr 24, 2017

May the @accessorder Attribute could help you?

@goetas goetas closed this as completed Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants