Rahul Sharma (Editor)

Binn (Serialization format)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Development status
  
Active

Platform
  
Cross-platform

License
  
Apache 2.0

Operating system
  
Any

Type
  
Data interchange

Website
  
github.com/liteserver/binn

Binn is a computer data serialization format used mainly for application data transfer. It stores primitive data types and data structures in a binary form.

Contents

Performance

The Binn format is designed to be compact and fast on readings. The elements are stored with their sizes to increase the read performance. The strings are null terminated so when read the library returns a pointer to them inside the buffer, avoiding memory allocation and data copying, an operation known as zero-copy.

Data types

Primitive data types:

  • null
  • boolean (true and false)
  • integer (up to 64 bits signed or unsigned)
  • floating point numbers (IEEE single/double precision)
  • string
  • blob (binary data)
  • User defined
  • Containers:

  • list
  • map (numeric key associative array)
  • object (text key associative array)
  • Format

    Binn structures consist of a list of elements. Each element has a type that can be followed by the size, count of internal items, and the data itself:

    boolean, null: [type] int, float (storage: byte, word, dword or qword): [type][data] string, blob: [type][size][data] list, object, map: [type][size][count][data]

    Example encoding

    A JSON data such as {"hello":"world"} is serialized in binn with the same size:

    Example code

    Writing to an object in C:

    Reading from that object:

    References

    Binn (Serialization format) Wikipedia


    Similar Topics