protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Javascript enviroment, Json to protobuf text format

Open zj91zj opened this issue 1 year ago • 0 comments

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' }

zj91zj avatar May 16 '24 02:05 zj91zj