mransan / ocaml-protoc

A Protobuf Compiler for OCaml
https://mransan.github.io/ocaml-protoc/
MIT License
179 stars 33 forks source link

Add support for encoding and decoding maps in JSON #220

Closed ddickstein closed 1 year ago

ddickstein commented 1 year ago

In the process, also add support for encoding and decoding unsigned values. The previous logic in field_pattern_match for decoding uint32 and uint64 wasn't valid, but that probably wasn't detected before since the encoder failed due to it being unsupported.

ddickstein commented 1 year ago

The last bullet in the docs on maps reads:

If you provide a key but no value for a map field, the behavior when the field is serialized is language-dependent. In C++, Java, Kotlin, and Python the default value for the type is serialized, while in other languages nothing is serialized.

I think this doesn't apply to the JSON encoding because I don't think there's a way to provide a key without a value in JSON, but if that's incorrect then we may need to do something here.