# Data serialization

# CBOR as Data serialization

We are using “Concise Binary Object Representation” or CBOR (opens new window) for data serialization in Zarb. All data structures like blocks or transactions or network messages are encoding using CBOR library. Key as integer: Key is always an integer regardless of the variable name. Key IDs are fixed and can never change.

An example of defining CBOR tags in golang:

type Account struct {
   Address  Address `cbor:"1,keyasint"`
   Number   int     `cbor:"2,keyasint"`
   Sequence int     `cbor:"3,keyasint"`
   Balance  int64   `cbor:"4,keyasint"`
}

# CBOR me!

http://cbor.me/ (opens new window) is a cool tool for digesting the CBOR binary data. You can try to decode binary data there, as seen in the following example:

000000   A4 01 54 43 6D 9A 52 FD  0E 4C 60 CA 8D D8 9F 75   ¤.TCm.Rý.L`Ê.Ø.u
000010   10 58 CF F4 0E DE E0 02  01 03 00 04 1A 1D CD 65   .XÏô.Þà.......Íe
000020   00                                                .

As you may have guessed, this is an example of account data in Zarb blockchain. The first field is a 20 bytes address, then an account number, sequence number and the balance which is 500000000.