ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
462 stars 101 forks source link

Add option to present all fields of a message for JSON #413

Open keyuebao opened 4 years ago

keyuebao commented 4 years ago

It’s surprising when Message.new(array: []).to_json_hash gets encoded to {}.

A decoded proto Message will still respond to the array field, supplying the default value. A JSON response however, will fail to do so. This seems inconsistent. Happy to submit a PR for this!