packAny function

Map<String, Object?> packAny(
  1. String typeUrl,
  2. Map<String, Object?> message
)

Packs a message into a google.protobuf.Any JSON representation.

The canonical proto3 JSON encoding of Any uses "@type" to carry the type URL and merges the message fields into the same object:

{"@type": "type.googleapis.com/my.Type", "field1": "value1"}

typeUrl should be a fully-qualified type URL (e.g. "type.googleapis.com/google.protobuf.Duration"). message is the message fields as a JSON-compatible map.

Implementation

Map<String, Object?> packAny(String typeUrl, Map<String, Object?> message) {
  return {'@type': typeUrl, ...message};
}