reznikmm / protobuf

The Google Protocol Buffers implementation in Ada
MIT License
32 stars 4 forks source link

JSON serialization support #9

Open mgrojo opened 2 years ago

mgrojo commented 2 years ago

Is JSON serialization supported? I suppose the answer is not, although I see some reference to JSON in the source.

Do you know if one could take the wire representation and then import json_util.h to get a JSON string? I suspect that it won't have the field names to make it.

reznikmm commented 2 years ago

Hello! No, currently JSON serialization isn't supported now. As I see functions in json_util.h requires TypeResolver object. If you find a way to create such an object, then they should work.

mgrojo commented 2 years ago

I suppose it could be obtained using the C++ generator, but what about doing it from Ada? I'm curious about what this code is for: https://github.com/reznikmm/protobuf/blob/3fca4fa058cf5d9b57e5d2319d8f1a82aaf5f52b/source/compiler/generated/google-protobuf-descriptor.adb#L1002

It seems that it's loading the JSON field names. If the data is actually loaded, it's a matter of adding the code to read the information and print the data in JSON format. Is that a workable approach?