-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
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
Mapping request payload works for JSON but not for XML #820
Comments
Random has to be a type. you should create a class that contains the fields hello, color, age. can't be just a plain array. An alternative solutioni is custom type handler. /**
* @Serializer\XmlRoot("data")
*/
class Data
{
/**
* @Serializer\Type("MyType")
*/
public $random;
} class MyHandler implements SubscribingHandlerInterface
{
public static function getSubscribingMethods()
{
return array(
array(
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
'format' => 'xml',
'type' => 'MyType',
'method' => 'deserializeMyType'
),
array(
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
'format' => 'xml',
'type' => 'MyType',
'method' => 'serializeMyType'
)
);
}
public function serializeAnyType(XmlSerializationVisitor $visitor, $data, array $type, Context $context)
{
// serialize your object here
}
public function deserializeAnyType(XmlDeserializationVisitor $visitor, $data, array $type)
{
// deserialize your object here
}
} |
Not sure which is the format for |
For unknown class properties: all we need is to achieve result below after sending an appropriate JSON and XML request payload.
If the model below works (it does!) for JSON then it should also work for XML by default.
I am happy to change the model as long as I can make XML mapping happy so I would be greateful if you could show me an example. Thanks |
checked right now, |
relates to schmittjoh#820 deserialize arrays with key-value pairs add test case with other values from default set current metadata from stack in serialization context
I have a model which is used to map JSON and XML payloads. JSON mapping works fine but XML doesn't. I asked similar question here but it was ignored with a passion!
Property
random
contains random/unknown/dynamic properties so I can not hardcode them. How do you map such properties?Thanks
MODEL
JSON
RESULT
XML
RESULT
This won't map either:
The text was updated successfully, but these errors were encountered: