Skip to content

[Serializer] By default the serializer do not convert to lower case properties #7626

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

Closed
wants to merge 3 commits into from

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Mar 14, 2017

No description provided.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lyrixx thanks for fixing this error! I added a small example to show that the conversion doesn't change the lower/uppercase of the method name.

@lyrixx lyrixx changed the title [Serializer] Bu default the serializer do not convert to lower case properties [Serializer] By default the serializer do not convert to lower case properties Mar 15, 2017
@lyrixx
Copy link
Member Author

lyrixx commented Mar 15, 2017

@javiereguiluz Thanks but actually it a bit more complex than that. The ObjectNormalizer use the property name for the name, but use the getter to get the value.

class Post
{
    private $publishedAt;
    
    public function getPublishedAt()
    {
        return $this->publishedAt;
    }
}

it will be serialized to {"publishedAt": "2017...."}"

@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 15, 2017

@lyrixx OK. Then I don't understand this phrase:

Objects are normalized to a map of property names (method name stripped
of the get/set/has/remove prefix) to property values.

By the way, I can understand your comment perfectly ... so maybe that's the description we should use.

@lyrixx
Copy link
Member Author

lyrixx commented Mar 15, 2017

Indeed, I don't understand the comment either...
maybe @dunglas could help us on this one.

@lyrixx
Copy link
Member Author

lyrixx commented Mar 15, 2017

May be we could explain how to add this name converter in the SE:

    serializer:
        enabled: true
        name_converter: serializer.name_converter.camel_case_to_snake_case

@HeahDude
Copy link
Contributor

ping @dunglas :)

@lyrixx
Copy link
Member Author

lyrixx commented Oct 16, 2017

ping @dunglas

@javiereguiluz
Copy link
Member

Should we close here? We have no more feedback or information about what to do 😞

@lyrixx
Copy link
Member Author

lyrixx commented Feb 9, 2018

No, you can merge as it

@@ -512,7 +512,7 @@ There are several types of normalizers available:
calling the constructor during the denormalization process.

Objects are normalized to a map of property names (method name stripped of
the "get"/"set"/"has"/"remove" prefix and converted to lower case) to property
Copy link
Member

@dunglas dunglas Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first letter is lower cased (getFoo -> foo), my sentence was unclear, indeed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So may I suggest: "Objects are normalized to a map of property names (method name stripped of the "get"/"set"/"has"/"remove" prefix and first letter converted to lower case) ..."

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, it's "obvious" that the conversion will occur

@javiereguiluz
Copy link
Member

Thanks Grégoire and Kévin! Merged on 2.7 branch.

javiereguiluz added a commit that referenced this pull request Feb 10, 2018
…lower case properties (lyrixx, javiereguiluz)

This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #7626).

Discussion
----------

[Serializer] By default the serializer do not convert to lower case properties

Commits
-------

16cad92 Minor reword
b384cc2 [Serializer] Added missing ObjectNormalizer
f7ebf56 [Serializer] By default the serializer do not convert to lower case properties
@lyrixx lyrixx deleted the patch-1 branch January 7, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants