tokio-rs / prost

PROST! a Protocol Buffers implementation for the Rust Language
Apache License 2.0
3.88k stars 504 forks source link

impl Message for serde_json::Value #404

Open danburkert opened 3 years ago

danburkert commented 3 years ago

For any application utilizing both protobuf and serde, it'd be better to use serde_json::Value in place of prost_types::Value. I believe (but haven't tested) that it's possible to get prost-build to output serde_json::Value instead of prost_types::Value using prost_build::Config::extern_path(".google.protobuf.Value", "::serde_json::Value"), however ::serde_json::Value doesn't impl Message, so this won't currently work.

The solution is to add an optional serde_json dependency to prost and conditionally add the impl.

danburkert commented 3 years ago

and/or perhaps add reflexive From impls to convert prost_types::Value <-> serde_json::Value

archseer commented 3 years ago

181 was an attempt at that.