diff --git a/src/JMS/Serializer/GraphNavigator.php b/src/JMS/Serializer/GraphNavigator.php index 87a4908f7..e8c27de04 100644 --- a/src/JMS/Serializer/GraphNavigator.php +++ b/src/JMS/Serializer/GraphNavigator.php @@ -26,6 +26,7 @@ use JMS\Serializer\Handler\HandlerRegistryInterface; use JMS\Serializer\EventDispatcher\EventDispatcherInterface; use JMS\Serializer\Metadata\ClassMetadata; +use JMS\Serializer\Util\String; use Metadata\MetadataFactoryInterface; use JMS\Serializer\Exception\InvalidArgumentException; @@ -140,6 +141,9 @@ public function accept($data, array $type = null, Context $context) // TODO: The rest of this method needs some refactoring. if ($context instanceof SerializationContext) { if (null !== $data) { + if(is_string($data)) { + $data = new String($data); + } if ($context->isVisiting($data)) { return null; } diff --git a/src/JMS/Serializer/Util/String.php b/src/JMS/Serializer/Util/String.php new file mode 100644 index 000000000..68a18f76a --- /dev/null +++ b/src/JMS/Serializer/Util/String.php @@ -0,0 +1,32 @@ + + */ +class String +{ + /** + * @var string + */ + private $content = null; + + /** + * @param string $content + */ + public function __construct($content) + { + $this->content = $content; + } + + /** + * @return string + */ + public function __toString() + { + return $this->content; + } +}