Skip to content

Protobufs just reinvented JSON

June 7, 2016

I’m not a super big fan of protocol buffers, but that is neither here nor there. With the new protocol buffer release, you can now completely reproduce JSON in protocol buffers with proto maps:

message JSON {
  oneof value {
    int64 i = 1;
    double f = 2;
    string s = 3;
    JSON_List l = 4;
    JSON_Map m = 5;
  }
}

message JSON_Map {
  map<string, JSON> m = 1;
}

message JSON_List {
  repeated JSON val = 1;
}

I can’t imagine why on earth you would want to do that, but I’m amused that you can.

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: