protobuf.js
protobuf.js copied to clipboard
Javascript enviroment, Json to protobuf text format
syntax = "proto2"; package proto;
import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions { optional string url = 55555; }
message Graph { optional string name = 1; optional string version = 2; repeated Vehicle vehicle = 11; }
message Vehicle { optional string name = 1; optional string ip = 2; }
I have a Graph json, for example: { name:'1', version:'1.0.0', vehicle:[{ name:'vehicle-1', ip: '127.0.0.1' }, { name:'vehicle-2', ip: '127.0.0.1' }] }
is there a tool to transform above json to below protobuf text
name: '1' version: '1.0.0' vehicle { name:'vehicle-1' ip: '127.0.0.1' } vehicle { name:'vehicle-2' ip: '127.0.0.1' }