CosmWasm / serde-json-wasm

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

deserialize_bytes and deserialize_byte_buf support for custom deserializers #63

Open luca992 opened 1 year ago

luca992 commented 1 year ago

I would like to be able to use my own deserializer to parse the raw bytes in my own project. This would allow me to do things like being able to deserialize untagged enums without needing to use serde_cw_value which increases my wasm size by about 200kb :/ .... Here's an example where I am able to deserialize an untagged enum #43 by trial and error since I have access to the raw bytes.

https://github.com/eqoty-labs/snip721-migratable/blob/0fc9028f497d2e5393d55209b9a49d24cea8d15a/contracts/snip721-migratable/src/msg_untagged_deserializer.rs

There very could be a better way to do this, but this is the best solution I have come up so far.

Plus giving people the ability to write custom deserializers with access to the raw bytes opens the door for other message serialization formats other than json.