Skip to content

Commit

Permalink
- improved Serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymtsots committed Jun 27, 2023
1 parent e380530 commit 7c7d99c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"license": [
"MIT"
],
"authors": [
{
"name": "SapientPro",
"email": "[email protected]",
"homepage": "https://sapient.pro/"
}
],
"require": {
"php": "^8.1",
"ext-mbstring": "*",
Expand Down
7 changes: 5 additions & 2 deletions src/Client/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
Expand All @@ -31,12 +32,14 @@ public function __construct()

public function deserialize(string $json, string $class): ?EbayModelInterface
{
return $this->serializer->deserialize($json, $class, 'json');
return $this->serializer->deserialize($json, $class, JsonEncoder::FORMAT);
}

public function serialize(EbayModelInterface $class): string
{
return $this->serializer->serialize($class, JsonEncoder::FORMAT);
return $this->serializer->serialize($class, JsonEncoder::FORMAT, [
AbstractObjectNormalizer::SKIP_NULL_VALUES => true
]);
}

public function denormalize(array $data, string $type): ?EbayModelInterface
Expand Down

0 comments on commit 7c7d99c

Please sign in to comment.