schmittjoh/JMSSerializerBundle — Issue #82: Serialize to array
Author: ruudk
Created: 2012-02-16 16:34:35+00:00
State: open

I want to embed my serialized object into an array that I want to encode to json. But that doesn't seem to work as the serializer json_encodes the object.

$serialized = $this->get('serializer')->serialize(new MyObject(), 'json');
echo json_encode(array(
'success' => true,
'result' => $serialized
);

I could `json_decode` my `$serialized` but that seems really ugly.

How should I fix this? Should there be an option on the `serialize` function to just return the `$visitor` instead of `$visitor->getResult()`? Or should I make my own handler?