js_object

Macro js_object 

Source
js_object!() { /* proc-macro */ }
Expand description

The js_value! macro creates a JsValue instance based on a JSON-like DSL.

assert_eq!(js_value!( 1 ), JsValue::from(1));
assert_eq!(js_value!( false ), JsValue::from(false));
// Objects and arrays cannot be compared with simple equality.
// To create arrays and objects, the context needs to be passed in.
assert_eq!(js_value!([ 1, 2, 3 ], context).display().to_string(), "[ 1, 2, 3 ]");
assert_eq!(
  js_value!({
    // Comments are allowed inside.
    "key": (js_string!("value"))
  }, context).display().to_string(),
  "{\n    key: \"value\"\n}",
);

Create a JsObject object from a simpler DSL that resembles JSON.