tendermint: Don't use `omitempty`

Types which are generated from proto files in go have JSON annotations which contain omitempty for all keys, for example: https://github.com/tendermint/tendermint/blob/62f97a69e97262b5feb57b1c2498f0c1e0e297b3/abci/types/types.proto#L137-L145

Results in this: https://github.com/tendermint/tendermint/blob/62f97a69e97262b5feb57b1c2498f0c1e0e297b3/abci/types/types.pb.go#L1711-L1720

Which means if you just make empty ResponseInfo{} and serialize it to JSON you would get empty JSON object, or if you do not set some field that field will be omitted from resulting JSON.

On the other hand, types defined by hand in go don’t use omitempty at all, all this results in inconsistency. As some fields are in json all the time and some aren’t, it makes writing parsers of request/response types unnecessarily harder in other statically typed languages.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

No problem!, happy for seeing response so fast 🙌

While we are at it, there is one type which I noticed in go side having no json annotations resulting in fields named LikeThis in json probably fixing it would be good too: https://github.com/tendermint/tendermint/blob/v0.32.2/types/tx.go#L85

As some fields are in json all the time and some aren’t, it makes writing parsers of request/response types unnecessarily harder in other statically typed languages.

I agree with the reasoning here, @melekes, thoughts?