Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
Created February 7, 2013 12:24
Show Gist options
  • Save mathiasverraes/4730589 to your computer and use it in GitHub Desktop.
Save mathiasverraes/4730589 to your computer and use it in GitHub Desktop.
<?php
class Thing
{
/**
* @JMS\Type("integer")
*/
private $fooBar;
public function getFooBar()
{
return $this->fooBar;
}
}
$json = '{"fooBar": 123}';
$deserializedThing = $serializer->deserialize($json, 'Thing', 'json');
assert(123, $deserializedThing->getFooBar());
// FAILS, we get null instead
// Adding @JMS\SerializedName("fooBar") resolves the issue
// Internally, the serializer converts fooBar to foo_bar unless instructed otherwise
@mathiasverraes
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment