'Pass JSON from Javascript to Rust-compiled WebAssembly as HashMap
How could I pass a JSON object from JS to a Rust function? Must all JSON objects with key value pairs be serialised before passing it in a call to an exported function from the compiled WASM? (Just primitive types, strings or integers for example)
Functions can be called passing a string easily, with Rust on the receiving end expecting a &str type. However, I can't figure out how I might specify the type for a JSON object. Using HashMap<&str, &str> results in an error with wasm-bindgen, with the message as follows:
the trait `wasm_bindgen::convert::FromWasmAbi` is not implemented for `std::collections::HashMap<&str, &str>`
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
