Tring to *.proto
-> json -generator-> other things
Tried pbjs, but the json can only hold one option, and no comment.
Is there any way to use the protoc to generate the json that represent the protos ?
Write a protoc generator is harder than work with the json.
EDIT
For example
With a proto like this
syntax = "proto2";
option java_package = "com.google.apps.jspb.proto";
import "google/protobuf/descriptor.proto";
package jspb.test;
message Empty {
}
enum OuterEnum {
FOO = 1;
BAR = 2;
}
message EnumContainer {
optional OuterEnum outer_enum = 1;
}
message Simple1 {
required string a_string = 1;
repeated string a_repeated_string = 2;
optional bool a_boolean = 3;
}
// etc etc
pbjs can generate a json that represent the proto def like this
{
"options": {
"java_package": "com.google.apps.jspb.proto",
"java_multiple_files": true
},
"nested": {
"jspb": {
"nested": {
"test": {
"nested": {
"Empty": {
"fields": {}
},
"OuterEnum": {
"values": {
"FOO": 1,
"BAR": 2
}
},
"EnumContainer": {
"fields": {
"outerEnum": {
"type": "OuterEnum",
"id": 1
}
}
},
"Simple1": {
"fields": {
"aString": {
"rule": "required",
"type": "string",
"id": 1
},
"aRepeatedString": {
"rule": "repeated",
"type": "string",
"id": 2
},
"aBoolean": {
"type": "bool",
"id": 3
}
}
}
}
}
}
}
}
}
So I can work with the json instead of protoc & proto. But pbjs is unmaintained, has a lot problem, trying to get these from protoc.
UPDATE
Seems what I want is the descriptor, just need a way to get the descriptor data out of protoc.