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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Fully standard JSON (no extensions).

“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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.