• 文库
  • 字符
  • 转换
  • 加密
  • 网络
  • 更多
    图表
    数学
    坐标
    图片
    文件
  • 文库
    字符
    转换
    加密
    网络
    更多
    图表
    数学
    坐标
    图片
    文件
logo 在线工具大全
0 评论 收藏 复制链接 分享

在线Protocol Buffers编码解码

标签 编码解码

数据在浏览器中处理,不会被上传到云端。
在数据中,是否有 varint 长度前缀。当编码解码多个消息时,需要开启 varint 长度前缀。
在线Protocol Buffers编码解码-工具简介

在线Protocol Buffers编码解码工具,支持在线解码 protocol buffers 数据,在线编码 protocol buffers 数据。支持打开多个 proto 定义文件,支持解码编码多个消息。

在线Protocol Buffers编码解码-使用说明

在线 Protocol Buffers 编码解码工具,支持输入 JSON 格式的数据,编码为 protobuf 二进制消息。 支持输入 hex, base64, binary 格式的 protobuf 二进制数据,解码为 JSON 数据。 支持编码解码单个消息和多个消息,支持手动输入 proto 定义或者打开多个 proto 文件。

  1. JSON 数据: 编码 - 输入 JSON 数据,根据选择消息类型,将 JSON 数据编码为选择的消息类型的 protobuf 二进制数据。 一次只能输入一个 JSON 消息数据进行编码。 解码 - 将输入的 protobuf 数据,解码为 JSON 格式的数据。如果 protobuf 数据中包含多个消息,多个消息将解码为 JSON 数组。
  2. Protobuf 数据: 编码 - 将输入的 JSON 消息,编码为 protobuf 数据,protobuf 二进制数据格式支持 hex, base64, binary 。 如果开启了 varint 长度前缀,则每个消息编码前,都会增加一个 varint 的长度字段。 多个 JSON 消息编码的 protobuf 二进制数据,将会连接在一起。 解码 - 将输入的 protobuf 二进制数据,解码为 JSON 数据。支持解码 varint 前缀的多消息二进制数据。
  3. proto 定义: 支持手动输入 proto 定义 或者打开 proto 文件。 打开 proto 文件时,支持打开多个 proto 文件,proto 定义文本框被设置为只读状态。点击 清空 后,会重新设置为可编辑状态。
  4. Protobuf 数据格式:protobuf 二进制数据的格式,支持 hex, base64, binary 。 打开 protobuf 数据文件时,二进制的文件内容将被转换为选择的数据格式。
  5. 消息类型:选择编码解码使用的 protobuf 消息类型。点击的刷新按钮时,将解析当前输入的 proto 定义或者打开的 proto 文件, 更新消息类型列表。
  6. varint 长度前缀: 编码 - 是否在消息前添加 varint 长度前缀字段。 解码 - 输入的 protobuf 数据,是否包含 varint 长度前缀。如果数据中包含多个消息,则必须包含 varint 长度前缀。
  7. bytes 类型说明: 编码 - 编码时支持输入 Array.<number>(number 为 8 比特整数,范围为 0-255) 或 base64 string 。 解码 - bytes 数据将被转换为 base64 string 。
  8. protobuf - js 数据类型对应关系:
    protobuf 字段类型 编码 JS 类型(encode)
    s-/u-/int32
    s-/fixed32
    number (32 bit integer)
    s-/u-/int64
    s-/fixed64
    Long-like (optimal)
    number (53 bit integer)
    float
    double
    number
    bool boolean
    string string
    bytes Uint8Array (optimal)
    Buffer (optimal under node)
    Array.<number> (8 bit integers)
    enum number (32 bit integer)
    message Valid message
    repeated T Array<T>
    map<K, V> Object<K,V>