From the course: Effective Serialization In Go: JSON, Protocol Buffers and More

Why do we need serialization?

- This course is about serialization. So, the first question you should ask is, why do we need it? If you look at the computer memory and the way it stores variables and other data, it's only done in bits and bytes. So here I have print Encoding where I'm going to print out int64 of this number, a floating point number and a string. And you can look at print Encoding. You're looking at the value and we are using the binary package to write it in a Little Endian format. Let's run this code. And let's view or toggle the debug. Console, yes this one, and now you see that there is a different representation in memory than the one that we are actually using in our program. So, the go language is hiding this detail from you, but when we start talking about the edges of your program, so when you have your program, with the middle one we have your code, and it can work with either the API layer, receiving and sending data to users, and with the storage layer, storing and retrieving data. It is always going to work in bytes, and then you need to explicitly convert the types that will work in your program into a sequence of bytes. And then you to need to convert the data you work in your program, stracks, strings, numbers, into a sequence of bytes. And this is what we're going to cover in this course. There are many serialization formats and several ways of working with them and we're going to see everything.

Contents