Created
February 7, 2013 12:24
-
-
Save mathiasverraes/4730589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to schmittjoh/serializer#33