Paste Search Dynamic
Recent pastes
Class Any
  1. public final class any
  2. extends com.google.protobuf.GeneratedMessageV3
  3. implements AnyOrBuilder
  4.  `any` contains an arbitrary serialized protocol buffer message along with a
  5.  url that describes the type of the serialized message.
  6.  Protobuf library provides support to pack/unpack any values in the form
  7.  of utility functions or additional generated methods of the any type.
  8.  Example 1: Pack and unpack a message in C++.
  9.      Foo foo = ...;
  10.      any any;
  11.      any.PackFrom(foo);
  12.      ...
  13.      if (any.UnpackTo(&foo)) {
  14.        ...
  15.      }
  16.  Example 2: Pack and unpack a message in Java.
  17.      Foo foo = ...;
  18.      any any = any.pack(foo);
  19.      ...
  20.      if (any.is(Foo.class)) {
  21.        foo = any.unpack(Foo.class);
  22.      }
  23.   Example 3: Pack and unpack a message in Python.
  24.      foo = Foo(...)
  25.      any = any()
  26.      any.Pack(foo)
  27.      ...
  28.      if any.Is(Foo.DESCRIPTOR):
  29.        any.Unpack(foo)
  30.        ...
  31.   Example 4: Pack and unpack a message in Go
  32.       foo := &pb.Foo{...}
  33.       any, err := ptypes.MarshalAny(foo)
  34.       ...
  35.       foo := &pb.Foo{}
  36.       if err := ptypes.UnmarshalAny(any, foo); err != nil {
  37.         ...
  38.       }
  39.  The pack methods provided by protobuf library will by default use
  40.  'type.googleapis.com/full.type.name' as the type url and the unpack
  41.  methods only use the fully qualified type name after the last '/'
  42.  in the type url, for example "foo.bar.com/x/y.z" will yield type
  43.  name "y.z".
  44.  JSON
  45.  ====
  46.  The JSON representation of an `any` value uses the regular
  47.  representation of the deserialized, embedded message, with an
  48.  additional field `@type` which contains the type url. Example:
  49.      package google.profile;
  50.      message Person {
  51.        string first_name = 1;
  52.        string last_name = 2;
  53.      }
  54.      {
  55.        "@type": "type.googleapis.com/google.profile.Person",
  56.        "firstName": <string>,
  57.        "lastName": <string>
  58.      }
  59.  if the embedded message type is well-known and has a custom JSON
  60.  representation, that representation will be embedded adding a field
  61.  `value` which holds the custom JSON in addition to the `@type`
  62.  field. Example (for message [google.protobuf.Duration][]):
  63.      {
  64.        "@type": "type.googleapis.com/google.protobuf.Duration",
  65.        "value": "1.212s"
  66.      }
  67.  
Parsed in 0.038 seconds