influxdata / pbjson

Auto-generate serde implementations for prost types
MIT License
89 stars 43 forks source link

Deserialize bytes (i.e. Vec<U8>) from a json array of integer #121

Open lpzantony opened 7 months ago

lpzantony commented 7 months ago

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<u8>) 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 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