influxdata / influxdata/pbjson
Deserialize bytes (i.e. Vec<U8>) from a json array of integer
- Dominant language
- Rust
- Stars
- 116
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
First of, thank you for your work on pbjson. It saves a lot of handcrafted serde fine tuning. Especially the fact that pbjson can deserialize enums either from their value or from their name, super handy.
One last thing I wonder about pbjson: it seems that the only way to deserialize a Protobuf `bytes` (i.e. a `Vec`) is to have it expressed as a base64 string, like `"data": "AAAH4AEM",`. If I do submit the following `"data": "[ 0, 0, 7, 224, 1, 12 ]",`, it returns an error because it expects a base64 string.
I know the official [Protobuf's recommendation for JSON mapping](https://protobuf.dev/programming-guides/proto3/#json) does recommend using base64 strings for `bytes`. I just wonder if it would be possible to also support deserialization of `bytes` from a JSON int array? Similarly to what is recommended for `repeated`.
Regards
AL
Contributor guide
Research direction
Start by tracing pbjson's generated serde deserialization for protobuf bytes and comparing it with the existing handling of repeated integer arrays. Confirm the expected behavior against the linked Protobuf JSON mapping guidance. Done means byte fields accept JSON integer arrays while retaining base64-string support, with coverage for both forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100