go-amino icon indicating copy to clipboard operation
go-amino copied to clipboard

Cannot json serialize map

Open ethanfrey opened this issue 7 years ago • 1 comments
trafficstars

JSON encoding handles primative types, structs, arrays, and anything with a registered handler, but it does not support maps. Maybe this is a design decision? https://github.com/tendermint/go-wire/blob/develop/json-encode.go#L16-L106

We need to use wire.Un/MarshalJSON() to serialize and deserialize all rpc endpoints and events, so they can handle the interfaces well. However, dump_consensus_state requires that we send a map over rpc: https://github.com/tendermint/tendermint/blob/breaking/wire-sdk2/rpc/core/types/responses.go#L105-L109

The key p2p.ID is an alias for string, so this is a standard json object. If we do not require determinism for wire.MarshalJSON, this should be easy. If we do, then maybe we can encode all maps as "CanonicalJSON" and this helps with that code in tendermint core as well.

ethanfrey avatar Feb 23 '18 18:02 ethanfrey

To clarify, this is needed to resolve an error in the tendermint -> new go-wire upgrade

ethanfrey avatar Feb 23 '18 18:02 ethanfrey