CosmWasm / serde-json-wasm

serde_json for Wasm programs (small, deterministic, no floats)
Apache License 2.0
30 stars 15 forks source link

Serialize u128/i128 as number instead of string #54

Closed webmaster128 closed 1 year ago

webmaster128 commented 1 year ago

Both serde-json and schemars assume u128 and i128 are serialized as a number. Since the JSON standard supports arbitrary length integers, this is actually valid. By serializing u128/i128 as strings we break ecosystem conventions which lead bugs down the road, especially since the JSON Schema and ts-codegen will generate a wrong type.

This change is clearly breaking, but a good candidate for a 1.0.0 release of this repo.


To illustrate the change, an example document looks like this:

 {
-    "amount": "9007199254740992"
+    "amount": 9007199254740992
 }