Skip to content
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

serialize_null setting without effect for arrays containing NULL values? #361

Closed
mgrobelin opened this issue Feb 12, 2014 · 1 comment
Closed

Comments

@mgrobelin
Copy link

Hello,

I'm using fos_rest & jms_serializer bundles to have some joy while building an api with symfony.

Depending on the setting fos_rest.serializer.serialize_null = (true|false) this structure...

$result = array();
$result["data"] = array(0, 1, NULL);
$result["more_data"] = NULL

... is going to be jsonized ...

/* fos_rest.serializer.serialize_null = true */
/* where is 3rd value in data ???? */
{
  "data": [
    0,
    1
  ],
  "more_data": null
}

... or ...

/* fos_rest.serializer.serialize_null = false */
{
  "data": [
    0,
    1
  ]
}
}

How comes null values in an array are removed from serialized result?

The controller code I'm using right now is this:

$result = array();
$result["data"] = array(0, 1, NULL);
$result["more_data"] = null;

$serialization_groups = array("public", "me");

$context = new SerializationContext();
$context->setGroups($serialization_groups);

$view = FOSView::create()
        ->setData($result)
        ->setSerializationContext($context);   
return $this->get('fos_rest.view_handler')->handle($view);
@goetas
Copy link
Collaborator

goetas commented Jan 5, 2017

Sorry for the loooong feedback look, this has been solved with schmittjoh/serializer#660

@goetas goetas closed this as completed Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants