feat: use json verify json

This commit is contained in:
2020-11-07 23:52:11 +08:00
parent 8bc89e80bb
commit cad9dfe606
3 changed files with 11 additions and 5 deletions

View File

@@ -46,11 +46,9 @@ impl QuickJSContext {
'_'
}).collect();
// TODO check JSON valid
// let v: Option<Vec<EmptyObject>> = serde_json::from_str(params).ok();
// if v.is_none() {
// return Err(rust_util::new_box_error("Params is not valid JSON array!"));
// }
if let Err(e) = json::parse(params) {
return Err(rust_util::new_box_error(&format!("Params is not valid JSON array: {}", e)));
}
self.context.eval(&format!("__PUBLIC_{}.apply(null, {})", f, params)).map_err(|e| e.into())
}
}