Self-describing data

Self-describing data carries type information along with the data. For example, the previous data might get encoded as

  1. table
  2. uint8 3
  3. uint 2
  4. string
  5. uint8 4
  6. []byte fred
  7. string
  8. uint8 10
  9. []byte programmer
  10. string
  11. uint8 6
  12. []byte liping
  13. string
  14. uint8 7
  15. []byte analyst
  16. string
  17. uint8 8
  18. []byte sureerat
  19. string
  20. uint8 7
  21. []byte manager

Of course, a real encoding would not normally be as cumbersome and verbose as in the example: small integers would be used as type markers and the whole data would be packed in as small a byte array as possible (XML provides a counter-example, though).
However, the principle is that the marshaller will generate such type information in the serialised data. The unmarshaller will know the type-generation rules and will be able to use this to reconstruct the correct data structure.