【问题标题】:Passing dynamic objects传递动态对象
【发布时间】:2021-10-14 15:22:48
【问题描述】:

一个 php 项目中有一组对象。我将它们表示为 JSON

{
  "name" : "foo",
  "type" : "bar",
  "context" : {
      //There is an arbitrary set of fields in which there can be integers, float, string, bool, as well as dictionaries and arrays
  }
}

如何将这些对象包装在 proto 中?

【问题讨论】:

    标签: protocol-buffers grpc


    【解决方案1】:

    要将任意 JSON 存储在协议缓冲区中,您可以使用来自 struct.protogoogle.protobuf.Value。在每种语言中,都有一种将 JSON 转换为 protobuf 的方法,使用这种类型,您可以处理任意 JSON。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 2021-04-28
      • 1970-01-01
      • 2021-06-25
      • 2018-04-17
      • 1970-01-01
      相关资源
      最近更新 更多