我要转换为protobuf文件(.proto文件)的以下javascript内容。我想知道如何将其另存为原始文件。 JS文件
{
package: null,
syntax: "proto2",
messages: [{
name: "Msg",
syntax: "proto2",
fields: [{
rule: "optional",
type: "Commands",
name: "command_number",
id: 1
}, {
rule: "optional",
type: "bytes",
name: "data",
id: 2
}, {
rule: "optional",
type: "int32",
name: "time",
id: 3
}],
enums: [{
name: "Commands",
syntax: "proto2",
values: [{
name: "chart_create_session",
id: 0
}, {
name: "chart_delete_session",
id: 1
}, {
name: "resolve_symbol",
id: 2
}, {
name: "create_series",
id: 3
}
}]
}]
}
答案 0 :(得分:1)
是一次性的事情
在这种情况下:
syntax = "proto2";
message Msg {
optional Commands command_number = 1;
optional bytes data = 2;
optional int32 time = 3;
}
enum Commands {
chart_create_session = 0;
chart_delete_session = 1;
resolve_symbol = 2;
create_series = 3;
}
message chart_create_session {
optional string session = 1;
optional string parameters = 2;
}