You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current approach to JSON marshalling of bignums is to encode them as huge JSON
numbers. This is technically in compliance with the JSON spec, but not actually
interoperable with other JSON implementations - and interop is the major reason to use
JSON instead of Gob.
I'm wondering if there is any way to revisit this, and marshal big numbers as strings?
Otherwise we are going to have to use wrapper structs around the crypto types so that we
can tack on a custom MarshalJSON implementation.
FWIW, marshalling as strings would also enable the serialization of rational bignums.
The text was updated successfully, but these errors were encountered:
Unfortunately it's not my struct, it's ecdsa.PublicKey (for example).
The only way I can see to fix it in general would be to add a flag to to the JSON
marshaler to make it interoperate with JS clients (such a flag could also affect the
serialization of int64 and uint64). Not a pretty solution though.
How should this work? A JsonMarshaller can return a byte containing arbitrarily
complex valid JSON.
I threw together a small-ish sample that attempts to illustrate my concerns. If
consensus can be reached about what this program should output, I might would like to
contribute code for this issue.