3 ms·
i think even if 3rd party API expects json, you could still map their models to proto ; i haven't encountered this case tho might still be challenging to convi
by dgan 1y ago
i think even if 3rd party API expects json, you could still map their models to proto ; i haven't encountered this case tho
might still be challenging to convince proto to output what you want exactly
- the__alchemist 1y agoI don't understand then. Here is my mental model; as described, you can see why I'm confused: JSON: UTF-8 Serialization format, where brackets, commas, fields represented by strings etc. Protobuf: Binary serialization format that makes liberal use of varints, including to define field number, lengths etc. Kind of verbose, but not heinous. So, you could start and end your journey with the same structs and serialize with either. If you try to send a protobuf to an HTTP API that expects JSON, it won't work! If you try to send JSON to an ESP32 running ESP-Hosted, likewise.
- dgan 1y agoah I think I understand your confusion. The proto package allows conversion between the binary messages and their json equivalent. So you can still use the proto objects in your code , only to send out json when required