| Crates.io | protobuf-to-json |
| lib.rs | protobuf-to-json |
| version | 0.1.1 |
| created_at | 2025-09-02 10:28:53.619032+00 |
| updated_at | 2025-09-03 14:08:41.53608+00 |
| description | A parser that converts arbitrary protobuf data to json |
| homepage | |
| repository | https://github.com/traceflight/protobuf-to-json |
| max_upload_size | |
| id | 1820978 |
| size | 57,380 |
A parser that converts arbitrary protobuf data to json
Add it to your Cargo.toml:
[dependencies]
protobuf-to-json = "0.1"
use protobuf_to_json::Parser;
use serde_json::json;
let data = [
0x0d, 0x1c, 0x00, 0x00, 0x00, 0x12, 0x03, 0x59, 0x6f, 0x75, 0x1a, 0x02, 0x4d, 0x65,
0x20, 0x2b, 0x2a, 0x0a, 0x0a, 0x06, 0x61, 0x62, 0x63, 0x31, 0x32, 0x33, 0x12, 0x00,
];
let parser = Parser::new();
let json = parser.parse(&data).unwrap();
println!("{}", json);
let expected = json!({
"1": 28,
"2": "You",
"3": "Me",
"4": 43,
"5": {
"1": "abc123",
"2": ""
}
});
assert_eq!(json, expected);
When parsing raw protobuf data without a .proto file, the performance comparison with protofish is as follows.
| crate | time | throughput |
|---|---|---|
| protofish (parse context) | 3.7243 µs | 101.15 MiB/s |
| protofish (not parse context) | 317.92 ns | 1.1571 GiB/s |
| protobuf-to-json | 172.50 ns | 2.1326 GiB/s |
For detailed performance test info, see parse_once.rs.
This project is licensed under either of
at your option.