pub struct JsoncOptions {
pub allow_trailing_comma: bool,
pub disallow_comments: bool,
}Expand description
The plugin options. Mirrors the TypeScript JsoncOptions type and the
pluginOpts map the Go Jsonc reads; both keys are off by default.
use tabnas_jsonc::JsoncOptions;
let options = JsoncOptions::new().with_allow_trailing_comma(true);
let parser = tabnas_jsonc::make_with(options);
assert_eq!(parser.parse("[1, 2, ]")?.to_string(), "[1,2]");Fields§
§allow_trailing_comma: boolAccept a trailing comma before a closing } or ]. Off, the
comma alternates are excluded from the grammar and [1,] is
rejected, which is what the JSONC dialect specifies by default.
disallow_comments: boolReject // and /* */ comments, leaving strict JSON (plus the
number and key relaxations jsonic keeps; see the README).
Implementations§
Source§impl JsoncOptions
impl JsoncOptions
Sourcepub fn with_allow_trailing_comma(self, allow: bool) -> Self
pub fn with_allow_trailing_comma(self, allow: bool) -> Self
Sourcepub fn with_disallow_comments(self, disallow: bool) -> Self
pub fn with_disallow_comments(self, disallow: bool) -> Self
Sourcepub fn from_value(value: &Value) -> Self
pub fn from_value(value: &Value) -> Self
Read the options out of an engine plugin option bag, the shape
Tabnas::use_plugin hands the plugin: allowTrailingComma and
disallowComments, each on only when it is exactly true, as the
Go toBool reads them. Anything else in the bag is ignored.
Sourcepub fn to_value(&self) -> Value
pub fn to_value(&self) -> Value
The options as an engine plugin option bag, with the TypeScript
key names, for Tabnas::use_plugin.
Trait Implementations§
Source§impl Clone for JsoncOptions
impl Clone for JsoncOptions
impl Copy for JsoncOptions
Source§impl Debug for JsoncOptions
impl Debug for JsoncOptions
Source§impl Default for JsoncOptions
impl Default for JsoncOptions
impl Eq for JsoncOptions
Source§impl PartialEq for JsoncOptions
impl PartialEq for JsoncOptions
impl StructuralPartialEq for JsoncOptions
Auto Trait Implementations§
impl Freeze for JsoncOptions
impl RefUnwindSafe for JsoncOptions
impl Send for JsoncOptions
impl Sync for JsoncOptions
impl Unpin for JsoncOptions
impl UnsafeUnpin for JsoncOptions
impl UnwindSafe for JsoncOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.