#serde #json #wasm

serde-json-wasm

serde_json for Wasm programs (small, deterministic, no floats)

9 releases

0.3.1 Jan 19, 2021
0.3.0 Jan 14, 2021
0.2.3 Jan 14, 2021
0.2.1 May 7, 2020
0.1.1 Oct 27, 2019

#27 in WebAssembly

Download history 2813/week @ 2021-06-06 4220/week @ 2021-06-13 3079/week @ 2021-06-20 3675/week @ 2021-06-27 3131/week @ 2021-07-04 3825/week @ 2021-07-11 5423/week @ 2021-07-18 3025/week @ 2021-07-25 4043/week @ 2021-08-01 3611/week @ 2021-08-08 3110/week @ 2021-08-15 3010/week @ 2021-08-22 3394/week @ 2021-08-29 3151/week @ 2021-09-05 3635/week @ 2021-09-12 4560/week @ 2021-09-19

8,345 downloads per month
Used in 62 crates (4 directly)

MIT/Apache

105KB
3K SLoC

serde-json-wasm

serde-json-wasm on crates.io Docs

A serde-json alternative for CosmWasm smart contracts.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

serde-json for wasm programs

This version of serde-json is aimed at applications that run on resource constrained devices.

Current features

  • The error type is a simple C like enum (less overhead, smaller memory footprint)
  • (De)serialization doesn't require memory allocations
  • Deserialization of integers doesn't go through u64; instead the string is directly parsed into the requested integer type. This avoids pulling in KBs of compiler intrinsics when targeting a non 64-bit architecture.
  • Supports deserialization of:
    • bool
    • Integers
    • str (This is a zero copy operation.) (*)
    • Option
    • Arrays
    • Tuples
    • Structs
    • C like enums
  • Supports serialization (compact format only) of:
    • bool
    • Integers
    • str
    • Option
    • Arrays
    • Tuples
    • Structs
    • C like enums

(*) Deserialization of strings ignores escaped sequences. Escaped sequences might be supported in the future using a different Serializer as this operation is not zero copy.

Planned features

  • (De)serialization from / into IO objects once core::io::{Read,Write} becomes a thing.

Non-features

This is explicitly out of scope

  • Anything that involves dynamic memory allocation
    • Like the dynamic Value type

MSRV

This crate is guaranteed to compile on stable Rust 1.31.0 and up. It might compile with older versions but that may change in any new patch release.

Dependencies

~145–265KB