ovvio/serializer

Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.

v1.0.0 2024-12-27 14:01 UTC

This package is auto-updated.

Last update: 2025-06-27 14:57:52 UTC


README

Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.

Technical Requirements & Installation

PHP 8.4 - Installation and Configuration

Composer (System Requirements)

To install run this:

composer require ovvio/serializer

Examples

<?php

...

use Ovvio\Component\Serializer\SerializerFactory;

...

/**
 * Example 1: JSON to array
 */
/** @var \Ovvio\Component\Serializer\SerializerInterface $serializer */
$serializer = SerializerFactory::create();

/** @var string $json */
$json = <<<JSON
{
    "foo": "Foo",
    "bar": "Bar"
}
JSON;

/** @var null|array $array */
$array = $serializer->jsonToArray(json: $json);

/**
 * Example 2: array to JSON
 */
/** @var array $array */
$array = [
    'foo' => 'Foo',
    'bar' => 'Bar',
];

/** @var string $json */
$json = $serializer->arrayToJson(array: $array);