Skip to content

boatingfisher/protobuf-json

 
 

Repository files navigation

protobuf-json

Moved from http://code.google.com/p/protobuf-json

Provide serialization and de-serialization of Google's protobuf Messages into/from JSON format. protobuf-json is written in python and depends on Google's protobuf compiler for python.

Quick Example

Using .proto file like this:

 message Person {
   required int32 id = 1;
   required string name = 2;
   optional string email = 3;
 }

You can encode and decode it to/from json:

 {
  "id": 123,
  "name": "person name",
  "email": "user@example.com"
 }

More complex example:

 message Book {
   required string title = 1;
   optional float price = 2;
   repeated Person authors = 3;
 }
 {
  "title": "Book example",
  "price": 12.7,
  "authors": [
   {
    "id": 123,
    "name": "person name",
    "email": "user@example.com"
   },
   {
    "id": 456,
    "name": "another person",
   }
  ]
 }

Todo

From version 2.3.0 protobuf protoc supports a plugin system for code generators. Plugins can generate code for new languages.

TODO: write JavaScript code generator

About

Protocol Buffers serialization to JSON for python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.8%
  • Protocol Buffer 5.2%