.proto 文件中“Value”类的含义是什么

Ash*_*ada 3 java protocol-buffers proto grpc grpc-java

有人可以解释我下面.proto文件中“值”的含义吗?

message Test {
string id = 1;
string name = 2;
google.protobuf.Value property = 6;}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ell 6

没有import它它可能不应该工作,但是:它代表一个灵活类型的值;在Value“众所周知的类型”本质上是一个工会(oneof几个常见的类型),与Java API(从标签)在这里描述

定义在struct.proto(因此你需要import "google/protobuf/struct.proto";),或者基本上:

message Value {
  // The kind of value.
  oneof kind {
    // Represents a null value.
    NullValue null_value = 1;
    // Represents a double value.
    double number_value = 2;
    // Represents a string value.
    string string_value = 3;
    // Represents a boolean value.
    bool bool_value = 4;
    // Represents a structured value.
    Struct struct_value = 5;
    // Represents a repeated `Value`.
    ListValue list_value = 6;
  }
}
Run Code Online (Sandbox Code Playgroud)