gRPCToolset线格式检查器
proto3 · 线格式
中文English

有 Schema 的序列化与反序列化

粘贴 .proto 源码,工具在内存中编译(无需 protoc),再用反射完成双向转换:字节 → 结构化字段 → JSON,以及 JSON → 字节。字段名、枚举名、嵌套消息、repeated 与 map 都按 schema 还原。

Schema 定义

proto
改动后点击「应用 Schema」编译;标准库 google/protobuf/* 可直接 import
Schema 已应用
已定义的消息(点击填入目标消息名)

反序列化:字节 → 结构

decode
输入 protobuf 字节或编码文本
反序列化完成
消息
helloworld.HelloReply
输入字节
10
字段数
3
未知字段
无
字段#类型基数值载荷字节
message1string可选"hi"6869
ts2int64可选1700000000
history3message helloworld.HelloRequestrepeated<未设置>
messagestring"hi"
#
1
基数
可选
载荷字节
6869
tsint641700000000
#
2
基数
可选
载荷字节
historymessage helloworld.HelloRequest<未设置>
#
3
基数
repeated
载荷字节

JSON

{
  "message": "hi",
  "ts": "1700000000"
}

序列化:JSON → 字节

encode
输入符合当前 Schema 的 JSON
序列化完成
消息
helloworld.HelloReply
输出字节
28
字段数
3

hex

0a0268691080e2cfaa061a100a046772706310031a01611a01622001

base64

CgJoaRCA4s+qBhoQCgRncnBjEAMaAWEaAWIgAQ==

字段结构

字段#类型基数值载荷字节
message1string可选"hi"6869
ts2int64可选1700000000
history3message helloworld.HelloRequestrepeated[]
messagestring"hi"
#
1
基数
可选
载荷字节
6869
tsint641700000000
#
2
基数
可选
载荷字节
historymessage helloworld.HelloRequest[]
#
3
基数
repeated
载荷字节