Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Commit01eb18d
committed
feature#42240 [Serializer] Add support for preserving empty object in object property (lyrixx)
This PR was merged into the 5.4 branch.Discussion----------[Serializer] Add support for preserving empty object in object property| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | yes| Deprecations? || Tickets |Fix#38192| License | MIT| Doc PR |This PR leveragehttps://symfony.com/blog/new-in-symfony-5-3-inlined-serialization-context tofix#38192.Example:```phpclass MyDto{ public function __construct( #[Context([AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true ])] public array $mapWithOption = [], #[Context([AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true ])] public array $mapWithOptionAndData = ['foo' => 'bar'], public array $mapWithoutOption = [], public array $mapWithoutOptionAndData = ['foo' => 'bar'], ) { }}```Will produce:```json{"mapWithOption":{},"mapWithOptionAndData":{"foo":"bar"},"mapWithoutOption":[],"mapWithoutOptionAndData":{"foo":"bar"}}```Commits-------c422e25 [Serializer] Add support for preserving empty object in object propertyFile tree
3 files changed
+9
-1
lines changed- src/Symfony/Component/Serializer
- Normalizer
- Tests
3 files changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
595 | 599 | | |
596 | 600 | | |
597 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
539 | 542 | | |
540 | 543 | | |
541 | 544 | | |
| |||
0 commit comments
Comments
(0)