Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serializer Demystified

Serializer Demystified

The Serializer is an essential tool when building APIs with Symfony. Knowing it in more detail can save you a lot of time when you want to customize how your data is handled. In this talk we will look at how the Symfony Serializer works by default by having a deeper look at the provided Normalizers and then we will look at some use cases for customizing both how data is serialized and deserialized.

6a1345d8e6dd15b2c78eff0c331963b1?s=128

Denis Brumann

December 03, 2020
Tweet

Transcript

  1. None
  2. SensioLabs Deutschland denis.brumann@sensiolabs.de @dbrumann

  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. Serializer normalize Serializer serialize() Normalizer Normalizer Normalizer Object Array supportsNormalization

  13. Serializer normalize Serializer serialize() Normalizer Object Array normalize

  14. Serializer normalize Serializer serialize() Normalizer Normalizer Normalizer Object Array supportsNormalization

    normalize
  15. Serializer normalize Serializer serialize() Normalizer Object Serializer encode Encoder JSON,

    XML, … Array encode
  16. None
  17. None
  18. None
  19. None
  20. Serializer decode Serializer deserialize() Decoder Object Serializer denormalize Denormalizer Array

    JSON, XML, …
  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. GetSetMethodNormalizer PropertyNormalizer ObjectNormalizer JsonSerializableNormalizer AbstractObjectNormalizer AbstractNormalizer

  29. GetSetMethodNormalizer get…, is…, has… set… PropertyNormalizer ObjectNormalizer

  30. GetSetMethodNormalizer get…, is…, has… set… PropertyNormalizer Reflection for accessing class

    attributes ObjectNormalizer
  31. GetSetMethodNormalizer get…, is…, has… set… PropertyNormalizer Reflection for accessing class

    attributes ObjectNormalizer Uses Symfony PropertyAccess: get…, is…, has… public properties add…/remove… for single entry in collections
  32. PropertyNormalizer GetSetMethodNormalizer

  33. PropertyNormalizer

  34. PropertyNormalizer GetSetMethodNormalizer ObjectNormalizer

  35. PropertyNormalizer GetSetMethodNormalizer ObjectNormalizer

  36. None
  37. Jane Mary Betty

  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None