首页 > 解决方案 > Protobuf3:如何将 Map Uint64 与 [jstype = JS_STRING] 一起使用

问题描述

我的原型:(AttributeResult 是消息)

message xResponse
{
  map < uint64, AttributeResult > attributes = 1;
}

我使用 nodejs 14.x

    "google-proto-files": "^2.4.0",
    "google-protobuf": "^3.15.6",
    "protocol-buffers": "^4.2.0"

我需要将长整数映射为映射中的键,但我不能在映射定义中使用 [jstype = JS_STRING],因为当我尝试生成 .js 文件时,我得到:x_messages.proto:59:3: jstype 只允许在 int64、uint64、sint64、fixed64 或 sfixed64 字段上使用。

无论如何,我可以使用 long 作为我的地图的键吗?谢谢你!

标签: node.jsproto3protocol-buffers

解决方案


推荐阅读