We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For example this code:
<?php require __DIR__.'/vendor/autoload.php'; class EmptyClass { } class NotEmptyClass { public $a = 1; } class WrapperClass { public $object; public function __construct($object) { $this->object = $object; } } $objects = [ 'stdClass' => new stdClass(), 'ArrayObject' => new ArrayObject(), 'EmptyClass' => new EmptyClass(), 'NotEmptyClass' => new NotEmptyClass(), 'DateTime' => new DateTime(), ]; foreach ($objects as $title => $object) { // data to serialize $item = [new WrapperClass($object)]; // serialize $json = JMS\Serializer\SerializerBuilder::create() ->addDefaultHandlers() ->addDefaultSerializationVisitors() ->addDefaultDeserializationVisitors() ->setCacheDir(__DIR__ . '/runtime') ->setDebug(true) ->build() ->serialize($item, 'json'); // output echo $title.':'.PHP_EOL; echo $json.PHP_EOL; echo str_repeat('-', 40).PHP_EOL; }
outputs:
stdClass: {"0":{"object":{}}} ---------------------------------------- ArrayObject: {"0":{"object":{}}} ---------------------------------------- EmptyClass: {"0":{"object":{}}} ---------------------------------------- NotEmptyClass: [{"object":{"a":1}}] ---------------------------------------- DateTime: [{"object":"2015-09-07T14:50:34+0600"}] ----------------------------------------
I think this is related to #373
The text was updated successfully, but these errors were encountered:
...which has been closed.
Sorry, something went wrong.
b0a46c8
No branches or pull requests
For example this code:
outputs:
I think this is related to #373
The text was updated successfully, but these errors were encountered: