Skip to content

Repository files navigation

Jobcloud Deserialization

Description

A simple deserialization.

Requirements

  • php: ^8.2
  • chubbyphp/chubbyphp-decode-encode: ^1.2
  • psr/http-message: ^1.1|^2.0
  • psr/log: ^2.0|^3.0.2

Suggest

  • chubbyphp/chubbyphp-container: ^2.2
  • pimple/pimple: ^3.5
  • psr/container: ^2.0.2
  • symfony/config: ^5.4.46|^6.4.14|^7.2 (symfony integration)
  • symfony/dependency-injection: ^5.4.46|^6.4.14|^7.2 (symfony integration)

Installation

composer require jobcloud/deserialization

Usage

Accessor

Denormalizer

Field Denormalizer

Relation Field Denormalizer

Denormalizer Context

DenormalizerObjectMappingRegistry

Deserializer

<?phpuseChubbyphp\DecodeEncode\Decoder\Decoder;
useChubbyphp\DecodeEncode\Decoder\JsonTypeDecoder;
useChubbyphp\DecodeEncode\Decoder\JsonxTypeDecoder;
useChubbyphp\DecodeEncode\Decoder\UrlEncodedTypeDecoder;
useChubbyphp\DecodeEncode\Decoder\XmlTypeDecoder;
useChubbyphp\DecodeEncode\Decoder\YamlTypeDecoder;
useChubbyphp\Deserialization\Denormalizer\Denormalizer;
useChubbyphp\Deserialization\Denormalizer\DenormalizerObjectMappingRegistry;
useChubbyphp\Deserialization\Deserializer;
useMyProject\Deserialization\ModelMapping;
useMyProject\Model\Model;
$logger...;
$deserializer = newDeserializer(
newDecoder([
newJsonTypeDecoder(),
newJsonxTypeDecoder(),
newUrlEncodedTypeDecoder(),
newXmlTypeDecoder(),
newYamlTypeDecoder()
]),
newDenormalizer(
newDenormalizerObjectMappingRegistry([
newModelMapping()
]),
$logger
)
);
$model = $deserializer->deserialize(
Model::class,
'{"name": "php"}',
'application/json'
);
echo$model->getName();
// 'php'print_r($deserializer->getContentTypes());
//[// 'application/json',// 'application/jsonx+xml',// 'application/x-www-form-urlencoded',// 'application/xml',// 'application/x-yaml'//]print_r($deserializer->decode(
'{"name": "php"}',
'application/json'
));
// ['name' => 'php']$model = $denormalizer->denormalize(
Model::class,
['name' => 'php']
);
echo$model->getName();
// 'php'

Mapping

DenormalizationFieldMapping

DenormalizationObjectMapping

LazyDenormalizationObjectMapping

Policy

ServiceFactory

chubbyphp-container

chubbyphp-laminas-config-factory

ServiceProvider

Copyright

2025 Dominik Zogg

About

A simple deserialization.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages