Skip to content

Serialize primitives and deep structures (array, hash) to protobuf

Notifications You must be signed in to change notification settings

arkency/protobuf-nested-struct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProtobufNestedStruct

Serialize your primitives, arrays and hashes using protobuf. Supports nested arrays and hashes.

Supported types:

  • nil
  • integer
  • float
  • boolean
  • string
  • date
  • time
  • hash (keys must be strings, values' types must be on this list)
  • array (elements' types must be on this list)

Inspired by google/protobuf/struct.proto but it can additionally handle Date, Time and Integer values.

Installation

Add this line to your application's Gemfile:

gem 'protobuf_nested_struct'

And then execute:

$ bundle

Or install it yourself as:

$ gem install protobuf_nested_struct

Usage

# store the serialized binary string in DB or send over network
serialized = ProtobufNestedStruct.dump(v)


# receive de-serialized binary string from DB or network 
copy = ProtobufNestedStruct.load(serialized)

expect(copy).to eql(obj)

where obj can be an instance of one of the supported types.

Protobuf schema definition

You can use it to generate code for serialization and deserialization in any programming language supported by Protobuf.

Development

  • bundle install
  • bundle exec rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/arkency/protobuf-nested-struct

Credits

About

Arkency

This repository is funded and maintained by Arkency. Check out our other open-source projects, especially Rails Event Store.

Consider hiring us to grow your Ruby/Rails apps and business. Make sure to check out our blog.