#[non_exhaustive]pub enum Dialect {
Json,
IJson,
Jsonc,
Jwcc,
Json5,
JsonLines,
}Expand description
A member of the JSON family. In the order JSON, JSONC, JWCC, JSON5, each one adds syntax to the
one before it. The one thing that does not carry over is where a // comment ends: JWCC ends
it at LF only, JSONC also at a lone CR, and JSON5 also at U+2028 and U+2029. I-JSON is JSON
with stricter content rules, and JSON Lines is one JSON value per line.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Json
JSON as RFC 8259 defines it.
IJson
I-JSON (RFC 7493): JSON whose lone surrogates, noncharacters and out-of-range numbers are errors. Duplicate keys are an error in every dialect.
Jsonc
JSON with // and /* */ comments.
Jwcc
JSON with comments and trailing commas, also called HuJSON.
Json5
JSON5 1.0.0.
JsonLines
JSON Lines: one JSON value per line, also called NDJSON.
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub const ALIASES: &'static [(&'static str, Dialect)]
pub const ALIASES: &'static [(&'static str, Dialect)]
Other names FromStr accepts, each with the dialect it stands for.
Sourcepub const EXTENSIONS: &'static [(&'static str, Dialect)]
pub const EXTENSIONS: &'static [(&'static str, Dialect)]
The file extensions jsonvet checks by default, without the dot, each with its dialect. Matching is case-sensitive.
Sourcepub const FILE_NAMES: &'static [(&'static str, Dialect)]
pub const FILE_NAMES: &'static [(&'static str, Dialect)]
Whole file names jsonvet checks by default, each with its dialect. These match the
complete name only: .babelrc, not a.babelrc.
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The name used on the command line and in config files, such as jsonc.
Sourcepub fn for_path(path: &Path) -> Option<Dialect>
pub fn for_path(path: &Path) -> Option<Dialect>
The default dialect for a file, from FILE_NAMES or else
EXTENSIONS, or None for a file jsonvet does not check by default.
.json files default to JSON5, because most .json files that fail as JSON are config
files with comments.