revision: use JSON compatible serializer (#2592)
This commit is contained in:
1 parent
9ca5396343
commit
4ccd9ffe19
1 file changed
+4
-1
@@ -4,6 +4,7 @@ use dioxus_html::document::{
|
|||||||
};
|
};
|
||||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||||
use js_sys::Function;
|
use js_sys::Function;
|
||||||
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
@@ -109,7 +110,9 @@ impl Evaluator for WebEvaluator {
|
|||||||
|
|
||||||
/// Sends a message to the evaluated JavaScript.
|
/// Sends a message to the evaluated JavaScript.
|
||||||
fn send(&self, data: serde_json::Value) -> Result<(), EvalError> {
|
fn send(&self, data: serde_json::Value) -> Result<(), EvalError> {
|
||||||
let data = match serde_wasm_bindgen::to_value::<serde_json::Value>(&data) {
|
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
||||||
|
|
||||||
|
let data = match data.serialize(&serializer) {
|
||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(e) => return Err(EvalError::Communication(e.to_string())),
|
Err(e) => return Err(EvalError::Communication(e.to_string())),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user