Mitchell McKenna - tagged with serializer http://mitchmckenna.com/feed en-us http://blogs.law.harvard.edu/tech/rss LifePress mitchellmckenna@gmail.com JMS Serializer - Convert objects to and from JSON, XML, YAML, etc http://mitchmckenna.com/post/15793/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc

Say you're building an API, you need to convert the objects you send in the response to JSON representation (removing certain properties like passwords, and modifying others like dates) you can use JSMSerializer to define how that happens automatically. But where JSMSerializer really shines is how it can deserialize data into PHP objects. Maybe you you are consuming a JSON feed, you can use this to convert each object in the JSON feed to an object. You do this by registering "handlers" for each object type. You can do all this configuration via annotations, XML or YAML (which you'll be familiar with if you've used Doctrine). It also includes an event system, which you can use to hook into modifying the data before serialization or right afterward it happens.

]]>
Sun, 27 Sep 2015 15:53:00 -0400 http://mitchmckenna.com/post/15793/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc