mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 17:21:35 +00:00
@ -3048,8 +3048,12 @@ pub mod WebAssembly {
|
|||||||
// JSON
|
// JSON
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
/// The `JSON` object contains methods for parsing [JavaScript Object
|
||||||
|
/// Notation (JSON)](https://json.org/) and converting values to JSON. It
|
||||||
|
/// can't be called or constructed, and aside from its two method
|
||||||
|
/// properties, it has no interesting functionality of its own.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[wasm_bindgen(extends = Object)]
|
||||||
pub type JSON;
|
pub type JSON;
|
||||||
|
|
||||||
/// The `JSON.parse()` method parses a JSON string, constructing the
|
/// The `JSON.parse()` method parses a JSON string, constructing the
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
use js_sys::*;
|
use js_sys::*;
|
||||||
@ -82,3 +82,15 @@ fn stringify_error() {
|
|||||||
let err_msg: String = From::from(err.message());
|
let err_msg: String = From::from(err.message());
|
||||||
assert!(err_msg.contains("rust really rocks"));
|
assert!(err_msg.contains("rust really rocks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn json_extends() {
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
#[wasm_bindgen(js_name = JSON)]
|
||||||
|
static json: JSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert!(json.is_instance_of::<Object>());
|
||||||
|
let _: &Object = json.as_ref();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user