-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
makes sure that explicit lists are serialized as lists
If you want to make sure something is formatted as a list, i.e. ``[1, 2, 3]`` in JSON, make sure to add an explicit type like ``@Type("array<integer>")``. closes #571 closes #572 closes #488 closes #304 ...and probably more
- Loading branch information
1 parent
602bd84
commit b0a46c8
Showing
7 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/JMS/Serializer/Tests/Fixtures/ObjectWithIntListAndIntMap.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace JMS\Serializer\Tests\Fixtures; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
class ObjectWithIntListAndIntMap | ||
{ | ||
/** @Serializer\Type("array<integer>") @Serializer\XmlList */ | ||
private $list; | ||
|
||
/** @Serializer\Type("array<integer,integer>") @Serializer\XmlMap */ | ||
private $map; | ||
|
||
public function __construct(array $list, array $map) | ||
{ | ||
$this->list = $list; | ||
$this->map = $map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/JMS/Serializer/Tests/Serializer/xml/array_list_and_map_difference.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<result> | ||
<list> | ||
<entry>1</entry> | ||
<entry>2</entry> | ||
<entry>3</entry> | ||
</list> | ||
<map> | ||
<entry _key="0">1</entry> | ||
<entry _key="2">2</entry> | ||
<entry _key="3">3</entry> | ||
</map> | ||
</result> |
8 changes: 8 additions & 0 deletions
8
tests/JMS/Serializer/Tests/Serializer/yml/array_list_and_map_difference.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
list: | ||
- 1 | ||
- 2 | ||
- 3 | ||
map: | ||
0: 1 | ||
2: 2 | ||
3: 3 |