-
-
Notifications
You must be signed in to change notification settings - Fork 587
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
Error deserializing a map of (nullable) objects #762
Comments
actually yes. if your type is |
Is there any workaround? |
you can specify the array as: class NullableVirutalUserHandler implements SubscribingHandlerInterface
{
public static function getSubscribingMethods()
{
$methods = array();
$methods[] = array(
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
'type' => 'NullableVirutalUser',
'format' => 'json',
'method' => 'deserializeNullableUser',
);
return $methods;
}
public function deserializeNullableUser(VisitorInterface $visitor, $data, array $type, Context $context)
{
if (!$data) { // null
return null;
} else {
return $context->accpet($data, ['name'=> 'User', 'params' => []], $context);
}
}
} maybe the syntax is no 100% correct, but hope you get the idea |
@goetas hello, will this be supported at some point? |
Hi folks!
We have a use case here where we need to deserialize an
array<string,User>
where a user can be null. Furthermore,User
has a couple of subclasses. Whenever we try to deserialize such map, we got the following error:Is this the expected behavior?
The text was updated successfully, but these errors were encountered: