Search code examples
stringserializationbinary-data

What are the advantages of strings for serialization?


What are the advantages of strings for serialization?

What's wrong with binary files for serialization?


Solution

    • String data is human-readable, which is wonderful for troubleshooting. Binary data is not.
    • String data is easily parsed by systems on any platform. Binary data is not always, so if you need to pass data between a Windows and a Linux box, or maybe an IBM Mainframe, string data is simpler.
    • String data also is comprehensive enough to include XML, which brings even better features to the table.
    • It's easier to truly encrypt and decrypt, particularly if you're going cross-platform.

    However, there are disadvantages to using string data as well.

    • It usually results in larger amounts of raw bits - larger files, more traffic on the network, etc.
    • It's human-readable which is not so wonderful if you need to protect it from being used in other systems or from prying eyes. (Although encryption helps with the prying eyes deal.)