GenesisBuilder: arbitrary_precision feature enabled for serde_json#2987
GenesisBuilder: arbitrary_precision feature enabled for serde_json#2987
GenesisBuilder: arbitrary_precision feature enabled for serde_json#2987Conversation
koute
left a comment
There was a problem hiding this comment.
Hmm.... as an alternative maybe we should consider serializing those numbers as strings instead, if possible?
The reason being that this is not really portable, so anyone who will try to load a JSON containing such numbers in any other language, using any other library, or just using serde_json without this flag will silently get incorrect results (if the library doesn't explicitly produce an error in such case, and I think almost all of them don't?).
|
json spec doesn't pose any limit to the number of bits for the As
However, I also understand @koute perplexities, i.e. popular libs and other lang implementations typically support up to u64 |
Would that means that also 64-bit integers would need to be serialized as
This for sure needs to be solved at some point. Strings would be possible, but that would require touching affected pallets. |
See discussion here: serde-rs/json#846 FWIS actually |
For perfect compatibility with everything, yes. (In languages where numbers are It is an open question whether we care, but it is a footgun that should be at the very least documented. |
You mean that other languages would fail to parse such a number? |
It's matter of json lib implementation. Some will do (ruby,python), some not (nodejs). From what I found this c++ json lib nlohmann/json is not able to parse it. |
…on` (paritytech#2987) [`arbitrary_precision`](https://github.com/serde-rs/json/blob/6d44b9fac9269b4decf76acac5d68e8ec9d10c58/Cargo.toml#L69-L75) feature allows to (de-)serialize big numbers w/o error. For some details refer also to paritytech#1256 (comment) fixes: paritytech#2963
arbitrary_precisionfeature allows to (de-)serialize big numbers w/o error.For some details refer also to #1256 (comment)
fixes: #2963