Skip to content

[Serializer] fix(serializer): missing empty_array_as_object in example #16977

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

Conversation

alanpoulain
Copy link
Contributor

@alanpoulain alanpoulain commented Jul 13, 2022

This PR:

  • Replaces empty_iterable_as_object by preserve_empty_objects, like it should be.
  • Adds empty_array_as_object to example in Serializer Context.
  • Removes the mention by default, since it's false by default.

Related:

@carsonbot carsonbot added this to the 5.4 milestone Jul 13, 2022
@carsonbot carsonbot changed the title fix(serializer): missing empty_array_as_object in example [Serializer] fix(serializer): missing empty_array_as_object in example Aug 8, 2022
@javiereguiluz
Copy link
Member

Thank you Alan.

@javiereguiluz javiereguiluz merged commit 90ff119 into symfony:5.4 Aug 8, 2022
javiereguiluz added a commit that referenced this pull request Apr 14, 2025
This PR was submitted for the 7.2 branch but it was squashed and merged into the 6.4 branch instead.

Discussion
----------

[Serializer] (re)document PRESERVE_EMPTY_OBJECTS

👋🏻
when implementing a web hook, I had to serialize en empty array as object, and found it was wrong (empty list not empty object)

```php
// json without flag
'data' => [],
"data":[],

// json with flag
'data' => new \ArrayObject(),
"data":{},

```
this PR (re)adds this feature as I thinks its useful to have it directly showcased in the main doc
weirdly it was present in v5.4 #16977

Commits
-------

ce28629 [Serializer] (re)document PRESERVE_EMPTY_OBJECTS
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.

3 participants