CosmWasm / serde-json-wasm

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

Docs say that deserialization without alloc is supported #66

Open leighmcculloch opened 9 months ago

leighmcculloch commented 9 months ago

The docs appear to say: https://github.com/CosmWasm/serde-json-wasm/blob/2ab22a6f3a741b4db507c464185d86beefc5bab6/src/lib.rs#L11 https://github.com/CosmWasm/serde-json-wasm/blob/2ab22a6f3a741b4db507c464185d86beefc5bab6/src/lib.rs#L15-L18

However, looking at the API, DeserializedOwned is required: https://github.com/CosmWasm/serde-json-wasm/blob/2ab22a6f3a741b4db507c464185d86beefc5bab6/src/de/mod.rs#L654-L656

What's the right way to use the lib to do deserialisation with &str fields being a zero copy?

Thanks!

webmaster128 commented 9 months ago

The docs are outdated, thank you for pointing this out. They are from the original serde-json-core.

For JSON neither serialization nor deseralization can be done zero-copy without heavily restricting the supported contents because of escaping. E.g.