1
votes

I have some trouble with JMS Serializer - I need to deserialize a XML but i have an exception.

For example, for the xml

<test><name>Test</name></test>

I'm doing :

$xml = $paramFetcher->get('xml');
$serializer = SerializerBuilder::create()->build();
$serializer->deserialize($stack, MyObject::class, 'xml');

And with that, JMS return :

<exception class="JMS\Parser\SyntaxErrorException" message="Expected end of input, but got &quot;&gt;&quot; of type T_CLOSE_BRACKET at position 37 (0-based).">

at JMS\Serializer\Serializer->deserialize('&lt;test&gt;&lt;name&gt;Test&lt;/name&gt;&lt;/test&gt;', 'MyObject::class', 'xml')

The XML is sent in POST 'form-data' with other RequestParam.

jms/serializer-bundle 2.4.2

1
could you try the full namespace of your class without forward slash like Foo\BarBundle\Entity\MyObject instead of MyObject::classjohn Smith
btw. you can easily find out the appropriate input by serializing one of your entities like $serializer->serialize($testObject,"xml") so you can see what jms expects for deserialisation, all the propertynames and types must matchjohn Smith
I tried with $serializer->deserialize($stack,'AppBundle\Model\MyObject', 'xml'); but i have the same problemHussein

1 Answers

0
votes

The problem was solved by changing a namespace in one of my entities. I checked all namespace, and one of this namespace was not correct.