pub fn plugin() -> PluginExpand description
The plugin form of jsonc, for Tabnas::use_plugin: the Rust
counterpart of tn.use(Jsonc, options) and j.Use(Jsonc, opts).
The option bag is the TypeScript one, allowTrailingComma and
disallowComments, read through JsoncOptions::from_value; both
default to off. Installed this way the plugin is re-applied to derived
instances, as every native plugin is.
let mut parser = tabnas_jsonic::make();
let options = tabnas_jsonc::JsoncOptions::new().with_disallow_comments(true);
parser.use_plugin(tabnas_jsonc::plugin(), Some(options.to_value()))?;
assert_eq!(parser.parse(r#"{"a":[1,2]}"#)?.to_string(), r#"{"a":[1,2]}"#);
assert!(parser.parse("[1] // no comments").is_err());