Struct smoljson::read::Dialect [−][src]
#[non_exhaustive]pub struct Dialect { pub allow_comments: bool, }
Expand description
A set of flags describing non-standard extensions to JSON.
Currently, this is just comments, but trailing commas may be added in the future.
Note: turning one of these flags on should never cause documents which were valid with that flag off to become invalid.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.allow_comments: bool
Allow JavaScript-style comments.
That is, if this is true, it ignores the text between single line
comments like // foo
, and block comments like /* bar */
.
Note that unlike Rust’s block comments, JavaScript’s (and, by extension,
Dialect::CJSON
’s), cannot be nested. E.g. /* /* this */ */
is
invalid.
Implementations
“JSON with Comments”, as understood by Visual Studio Code.
This is standard/strict JSON, but with support for JavaScript’s comment syntax.
See https://github.com/microsoft/node-jsonc-parser for more details.
The default settings.
This is used with the plain Reader::new
, when using
s.parse::<Value>()
(or Value::from_str
), etc. It can be controlled
by cargo features.
The settings here can be controlled by cargo features.
features = ["default_allow_comments"]
: enablesDialect::allow_comments
by default.
All extensions enabled.
When new options are added, this constant will be updated to have them set to true.
Use of this is not always the best idea, as there’s no telling what kind of terrible extension the fool who maintains this crate decides to add in the future…
(That said, the dialect flags are intended to be strictly additive — they should never cause documents that parsed without the flag to fail to parse with it, so using this shouldn’t cause your code to unexpectedly break)
Trait Implementations
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more